Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
buildPlugin(configurations: [
[ platform: 'linux', jdk: '11' ],
[ platform: 'windows', jdk: '11' ]
/*
See the documentation for more options:
https://github.com/jenkins-infra/pipeline-library/
*/
buildPlugin(
forkCount: '1C', // run this number of tests in parallel for faster feedback. If the number terminates with a 'C', the value will be multiplied by the number of available CPU cores
useContainerAgent: true, // Set to `false` if you need to use Docker for containerized tests
configurations: [
[platform: 'linux', jdk: 21],
[platform: 'windows', jdk: 17],
])
38 changes: 21 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.50</version>
<version>5.18</version>
<relativePath />
</parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>delphix</artifactId>
<version>3.2.2-SNAPSHOT</version>
<packaging>hpi</packaging>
<properties>
<jenkins.version>2.346.1</jenkins.version>
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
<jenkins.baseline>2.479</jenkins.baseline>
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
<hpi.compatibleSinceVersion>3.0.0</hpi.compatibleSinceVersion>
</properties>

Expand Down Expand Up @@ -48,8 +50,8 @@
<dependency>
<!-- Pick up common dependencies for the selected LTS line: https://github.com/jenkinsci/bom#usage -->
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.346.x</artifactId>
<version>1409.v7659b_c072f18</version>
<artifactId>bom-${jenkins.baseline}.x</artifactId>
<version>4948.vcf1d17350668</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -58,21 +60,28 @@

<dependencies>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.8.0</version>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>jackson2-api</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
<groupId>io.jenkins.plugins</groupId>
<artifactId>gson-api</artifactId>
</dependency>
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>okhttp-api</artifactId>
</dependency>
<dependency>
<groupId>io.jenkins.plugins</groupId>
<artifactId>commons-lang3-api</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plain-credentials</artifactId>
<artifactId>credentials</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<artifactId>plain-credentials</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
Expand Down Expand Up @@ -102,12 +111,7 @@
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-common</artifactId>
<version>1.6.20</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
<version>1.9.22</version>
</dependency>
</dependencies>

Expand Down
18 changes: 10 additions & 8 deletions src/main/java/io/jenkins/plugins/delphix/DeleteVDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import static io.jenkins.plugins.util.CredentialUtil.getAllCredentialsListBoxModel;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import javax.servlet.ServletException;

import edu.umd.cs.findbugs.annotations.NonNull;
import jakarta.servlet.ServletException;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.DataBoundConstructor;
Expand Down Expand Up @@ -59,6 +60,7 @@ public boolean isApplicable(Class<? extends AbstractProject> aClass) {
return true;
}

@NonNull
@Override
public String getDisplayName() {
return Messages.Delete_DisplayName();
Expand All @@ -71,16 +73,16 @@ public ListBoxModel doFillCredentialIdItems(@AncestorInPath Item item,

public FormValidation doCheckCredentialId(@QueryParameter String value)
throws IOException, ServletException {
if (value.length() == 0)
if (value.isEmpty())
return FormValidation.error(Messages.Credential_Empty());
return FormValidation.ok();
}

}

@Override
public void perform(Run<?, ?> run, FilePath workspace, EnvVars env, Launcher launcher,
TaskListener listener) throws InterruptedException, IOException {
public void perform(Run<?, ?> run, @NonNull FilePath workspace, @NonNull EnvVars env, @NonNull Launcher launcher,
@NonNull TaskListener listener) throws InterruptedException, IOException {
Helper helper = new Helper(listener);
listener.getLogger().println(Messages.Delete_Start(run.getId()));
try {
Expand All @@ -99,18 +101,18 @@ public void perform(Run<?, ?> run, FilePath workspace, EnvVars env, Launcher lau
}
}
else if (vdbId != null) {
List<String> vdbList = Arrays.asList(vdbId.split(","));
String[] vdbList = vdbId.split(",");
for (String vdb : vdbList) {
listener.getLogger().println(Messages.Delete_Message3(vdb));
deleteVDB(run, vdb, listener, dctSdkUtil);
}
}
else if (name != null) {
List<String> nameList = Arrays.asList(name.split(","));
String[] nameList = name.split(",");
for (String vdbname : nameList) {
listener.getLogger().println(Messages.Delete_Message5(vdbname));
SearchVDBsResponse result = dctSdkUtil.searchVDB(vdbname);
if (result.getItems().size() == 0) {
if (result.getItems().isEmpty()) {
listener.getLogger().println(Messages.Delete_Error3(vdbname));
run.setResult(Result.FAILURE);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.jenkins.plugins.delphix;

import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.EnvVars;
import hudson.Extension;
import hudson.FilePath;
Expand All @@ -20,7 +21,7 @@
import io.jenkins.plugins.vdb.VDBRequestBuilder;
import java.io.IOException;

import javax.servlet.ServletException;
import jakarta.servlet.ServletException;

import jenkins.tasks.SimpleBuildStep;
import org.jenkinsci.Symbol;
Expand Down Expand Up @@ -52,6 +53,7 @@ public String getBookmarkId() {
@Extension
public static final class ProvisionDescriptor extends BuildStepDescriptor<Builder> {

@NonNull
@Override
public String getDisplayName() {
return Messages.ProvisionVDBBookmark_DisplayName();
Expand All @@ -69,7 +71,7 @@ public boolean isApplicable(Class<? extends AbstractProject> jobType) {

public FormValidation doCheckCredentialId(@QueryParameter String value)
throws IOException, ServletException {
if (value.length() == 0)
if (value.isEmpty())
return FormValidation.error(Messages.Credential_Empty());
return FormValidation.ok();
}
Expand Down Expand Up @@ -104,16 +106,16 @@ public FormValidation doCheckJsonParam(@QueryParameter String value)

public FormValidation doCheckBookmarkId(@QueryParameter String value)
throws IOException, ServletException {
if (value.length() == 0)
if (value.isEmpty())
return FormValidation.error(Messages.BookmarkId_Empty());
return FormValidation.ok();
}

}

@Override
public void perform(Run<?, ?> run, FilePath workspace, EnvVars env, Launcher launcher,
TaskListener listener) throws InterruptedException, IOException {
public void perform(Run<?, ?> run, @NonNull FilePath workspace, @NonNull EnvVars env, @NonNull Launcher launcher,
@NonNull TaskListener listener) throws InterruptedException, IOException {
VDBRequestBuilder vdbRequestBuilder = new VDBRequestBuilder();
Helper helper = new Helper(listener);
listener.getLogger().println(Messages._ProvisionVDBBookmark_Info(run.getId()));
Expand All @@ -134,7 +136,7 @@ public void perform(Run<?, ?> run, FilePath workspace, EnvVars env, Launcher lau
listener.getLogger().println(
Messages.ProvisionVDB_Start(provisionResponse.getVdbId(), job.getId()));
JobHelper jobHelper = new JobHelper(dctSdkUtil, listener, job.getId());
boolean status = false;
boolean status;
if (skipPolling) {
status = jobHelper.waitForGetVDB( run,
provisionResponse.getVdbId());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.jenkins.plugins.delphix;

import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.EnvVars;
import hudson.Extension;
import hudson.FilePath;
Expand All @@ -19,7 +20,7 @@
import io.jenkins.plugins.util.ValidationUtil;
import io.jenkins.plugins.vdb.VDBRequestBuilder;
import java.io.IOException;
import javax.servlet.ServletException;
import jakarta.servlet.ServletException;

import jenkins.tasks.SimpleBuildStep;
import org.jenkinsci.Symbol;
Expand Down Expand Up @@ -56,6 +57,7 @@ public void setSnapshotId(String snapshotId) {
@Extension
public static final class ProvisionDescriptor extends BuildStepDescriptor<Builder> {

@NonNull
@Override
public String getDisplayName() {
return Messages.ProvisionVDBSnapshot_DisplayName();
Expand All @@ -73,7 +75,7 @@ public boolean isApplicable(Class<? extends AbstractProject> jobType) {

public FormValidation doCheckCredentialId(@QueryParameter String value)
throws IOException, ServletException {
if (value.length() == 0)
if (value.isEmpty())
return FormValidation.error(Messages.Credential_Empty());
return FormValidation.ok();
}
Expand Down Expand Up @@ -108,8 +110,8 @@ public FormValidation doCheckJsonParam(@QueryParameter String value)
}

@Override
public void perform(Run<?, ?> run, FilePath workspace, EnvVars env, Launcher launcher,
TaskListener listener) throws InterruptedException, IOException {
public void perform(Run<?, ?> run, @NonNull FilePath workspace, @NonNull EnvVars env, @NonNull Launcher launcher,
@NonNull TaskListener listener) throws InterruptedException, IOException {
VDBRequestBuilder vdbRequestBuilder = new VDBRequestBuilder();
Helper helper = new Helper(listener);
listener.getLogger().println(Messages._ProvisionVDBSnapshot_Info(run.getId()));
Expand All @@ -130,7 +132,7 @@ public void perform(Run<?, ?> run, FilePath workspace, EnvVars env, Launcher lau
listener.getLogger().println(
Messages.ProvisionVDB_Start(provisionResponse.getVdbId(), job.getId()));
JobHelper jobHelper = new JobHelper(dctSdkUtil, listener, job.getId());
boolean status = false;
boolean status;
if (skipPolling) {
status = jobHelper.waitForGetVDB( run,
provisionResponse.getVdbId());
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/io/jenkins/plugins/delphix/ProvisonVDB.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package io.jenkins.plugins.delphix;

import java.util.List;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.kohsuke.stapler.DataBoundSetter;

import hudson.tasks.Builder;

@SuppressFBWarnings(value = "PA_PUBLIC_PRIMITIVE_ATTRIBUTE", justification = "legacy code")
public abstract class ProvisonVDB extends Builder {
public boolean autoSelectRepository;
public List<Tags> tagList;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/io/jenkins/plugins/delphix/Tags.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

package io.jenkins.plugins.delphix;

import edu.umd.cs.findbugs.annotations.NonNull;
import org.kohsuke.stapler.DataBoundConstructor;
import hudson.Extension;
import hudson.model.AbstractDescribableImpl;
Expand Down Expand Up @@ -35,6 +36,7 @@ public DescriptorImpl getDescriptor() {
*/
@Extension
public static class DescriptorImpl extends Descriptor<Tags> {
@NonNull
@Override
public String getDisplayName() {
return "";
Expand Down
1 change: 0 additions & 1 deletion src/main/java/io/jenkins/plugins/job/JobHelper.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.jenkins.plugins.job;

import com.delphix.dct.ApiClient;
import com.delphix.dct.ApiException;
import com.delphix.dct.models.Job;
import com.delphix.dct.models.VDB;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private void writeMap(Map<String, Object> vdbDetails) {
catch (IOException e) {
this.listener.getLogger().print(e.getMessage());
}
try (FileOutputStream fileOut = new FileOutputStream(this.file, false);) {
try (FileOutputStream fileOut = new FileOutputStream(this.file, false)) {
for (Map.Entry<String, Object> entry : vdbDetails.entrySet()) {
this.properties.put(entry.getKey(), entry.getValue().toString());
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/jenkins/plugins/util/CredentialUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import com.cloudbees.plugins.credentials.CredentialsMatchers;
import com.cloudbees.plugins.credentials.CredentialsProvider;
import com.cloudbees.plugins.credentials.common.StandardListBoxModel;
import edu.umd.cs.findbugs.annotations.Nullable;
import hudson.model.Item;
import hudson.model.Run;
import hudson.security.ACL;
import hudson.util.ListBoxModel;
import hudson.util.Secret;

import javax.annotation.Nullable;
import java.util.Collections;
import org.jenkinsci.plugins.plaincredentials.StringCredentials;

Expand All @@ -30,7 +30,7 @@ public static ListBoxModel getAllCredentialsListBoxModel(@Nullable final Item it
}
}
return result.includeEmptyValue()
.includeMatchingAs(ACL.SYSTEM, item, StringCredentials.class,
.includeMatchingAs(ACL.SYSTEM2, item, StringCredentials.class,
Collections.emptyList(), CredentialsMatchers.always())
.includeCurrentValue(credentialId);
}
Expand Down
Loading