diff --git a/src/main/java/io/jenkins/plugins/jfrog/ArtifactoryInstaller.java b/src/main/java/io/jenkins/plugins/jfrog/ArtifactoryInstaller.java index 33e4c4d3..2ee16334 100644 --- a/src/main/java/io/jenkins/plugins/jfrog/ArtifactoryInstaller.java +++ b/src/main/java/io/jenkins/plugins/jfrog/ArtifactoryInstaller.java @@ -10,6 +10,8 @@ import io.jenkins.plugins.jfrog.configuration.JFrogPlatformBuilder; import io.jenkins.plugins.jfrog.configuration.JFrogPlatformInstance; import io.jenkins.plugins.jfrog.plugins.PluginsUtils; +import lombok.Getter; +import lombok.Setter; import org.apache.commons.lang3.StringUtils; import org.jfrog.build.client.Version; import org.kohsuke.stapler.DataBoundConstructor; @@ -26,6 +28,7 @@ * * @author gail */ +@Getter @SuppressWarnings("unused") public class ArtifactoryInstaller extends BinaryInstaller { private static final Version MIN_CLI_VERSION = new Version("2.6.1"); @@ -35,7 +38,8 @@ public class ArtifactoryInstaller extends BinaryInstaller { final String serverId; final String repository; - final String version; + @Setter + String version; @DataBoundConstructor public ArtifactoryInstaller(String serverId, String repository, String version) { @@ -45,18 +49,6 @@ public ArtifactoryInstaller(String serverId, String repository, String version) this.version = StringUtils.trim(version); } - public String getServerId() { - return serverId; - } - - public String getRepository() { - return repository; - } - - public String getVersion() { - return version; - } - @Override public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { JFrogPlatformInstance server = getSpecificServer(getServerId()); @@ -72,7 +64,7 @@ public FilePath performInstallation(ToolInstallation tool, Node node, TaskListen */ JFrogPlatformInstance getSpecificServer(String id) { List jfrogInstances = JFrogPlatformBuilder.getJFrogPlatformInstances(); - if (jfrogInstances != null && jfrogInstances.size() > 0) { + if (jfrogInstances != null && !jfrogInstances.isEmpty()) { for (JFrogPlatformInstance jfrogPlatformInstance : jfrogInstances) { if (jfrogPlatformInstance.getId().equals(id)) { // Getting credentials diff --git a/src/main/java/io/jenkins/plugins/jfrog/JfrogInstallation.java b/src/main/java/io/jenkins/plugins/jfrog/JfrogInstallation.java index 2bbe7eae..b6c6ee33 100644 --- a/src/main/java/io/jenkins/plugins/jfrog/JfrogInstallation.java +++ b/src/main/java/io/jenkins/plugins/jfrog/JfrogInstallation.java @@ -110,7 +110,7 @@ public JfrogInstallation newInstance(StaplerRequest req, JSONObject formData) th public List getDefaultInstallers() { List installersList = new ArrayList<>(); // The default installation will be from 'releases.jfrog.io' - installersList.add(new ReleasesInstaller(null)); + installersList.add(new ReleasesInstaller()); return installersList; } diff --git a/src/main/java/io/jenkins/plugins/jfrog/ReleasesInstaller.java b/src/main/java/io/jenkins/plugins/jfrog/ReleasesInstaller.java index 2680f19d..467b4769 100644 --- a/src/main/java/io/jenkins/plugins/jfrog/ReleasesInstaller.java +++ b/src/main/java/io/jenkins/plugins/jfrog/ReleasesInstaller.java @@ -8,6 +8,7 @@ import io.jenkins.plugins.jfrog.configuration.JFrogPlatformInstance; import org.apache.commons.lang3.StringUtils; import org.kohsuke.stapler.DataBoundConstructor; +import org.kohsuke.stapler.DataBoundSetter; import org.kohsuke.stapler.QueryParameter; import org.kohsuke.stapler.verb.POST; @@ -23,8 +24,13 @@ public class ReleasesInstaller extends ArtifactoryInstaller { private static final String RELEASES_REPOSITORY = "jfrog-cli"; @DataBoundConstructor - public ReleasesInstaller(String version) { - super("", RELEASES_REPOSITORY, version); + public ReleasesInstaller() { + super("", RELEASES_REPOSITORY, ""); + } + + @DataBoundSetter + public void setVersion(String version) { + super.setVersion(version); } @Override diff --git a/src/test/java/io/jenkins/plugins/jfrog/integration/PipelineTestBase.java b/src/test/java/io/jenkins/plugins/jfrog/integration/PipelineTestBase.java index 57b09488..9cba91a9 100644 --- a/src/test/java/io/jenkins/plugins/jfrog/integration/PipelineTestBase.java +++ b/src/test/java/io/jenkins/plugins/jfrog/integration/PipelineTestBase.java @@ -284,7 +284,9 @@ private String readPipeline(String name) throws IOException { } public static void configureJfrogCliFromReleases(String cliVersion, Boolean override) throws Exception { - configureJfrogCliTool(JFROG_CLI_TOOL_NAME_1, new ReleasesInstaller(cliVersion), override); + ReleasesInstaller releasesInstaller = new ReleasesInstaller(); + releasesInstaller.setVersion(cliVersion); + configureJfrogCliTool(JFROG_CLI_TOOL_NAME_1, releasesInstaller, override); } public static void configureJfrogCliFromArtifactory(String toolName, String serverId, String repo, Boolean override) throws Exception {