From f54af5c3ecf4835a27fffe5cb60a616317a413c3 Mon Sep 17 00:00:00 2001 From: delarea Date: Mon, 9 Sep 2024 14:23:46 +0300 Subject: [PATCH 1/5] Remove JF command from a freestyle project as it is confusing --- src/main/java/io/jenkins/plugins/jfrog/JfStep.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/io/jenkins/plugins/jfrog/JfStep.java b/src/main/java/io/jenkins/plugins/jfrog/JfStep.java index 9a721ee1..09d868ef 100644 --- a/src/main/java/io/jenkins/plugins/jfrog/JfStep.java +++ b/src/main/java/io/jenkins/plugins/jfrog/JfStep.java @@ -7,10 +7,7 @@ import hudson.Extension; import hudson.FilePath; import hudson.Launcher; -import hudson.model.AbstractProject; -import hudson.model.Job; -import hudson.model.Run; -import hudson.model.TaskListener; +import hudson.model.*; import hudson.tasks.BuildStepDescriptor; import hudson.tasks.Builder; import hudson.util.ArgumentListBuilder; @@ -291,7 +288,8 @@ public String getDisplayName() { @Override public boolean isApplicable(Class jobType) { - return true; + // Return false to hide it in Freestyle jobs + return !FreeStyleProject.class.isAssignableFrom(jobType); } } } From 31e5af1257ab186c4545487f4bd97d42f530806f Mon Sep 17 00:00:00 2001 From: delarea Date: Mon, 9 Sep 2024 14:30:46 +0300 Subject: [PATCH 2/5] Optimize imports --- src/main/java/io/jenkins/plugins/jfrog/JfStep.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/jenkins/plugins/jfrog/JfStep.java b/src/main/java/io/jenkins/plugins/jfrog/JfStep.java index 09d868ef..ad57b4b0 100644 --- a/src/main/java/io/jenkins/plugins/jfrog/JfStep.java +++ b/src/main/java/io/jenkins/plugins/jfrog/JfStep.java @@ -7,7 +7,11 @@ import hudson.Extension; import hudson.FilePath; import hudson.Launcher; -import hudson.model.*; +import hudson.model.AbstractProject; +import hudson.model.Job; +import hudson.model.Run; +import hudson.model.TaskListener; +import hudson.model.FreeStyleProject; import hudson.tasks.BuildStepDescriptor; import hudson.tasks.Builder; import hudson.util.ArgumentListBuilder; From bd2fccc6e70b32c52d89ce4d2660504352a8d9c8 Mon Sep 17 00:00:00 2001 From: delarea Date: Mon, 9 Sep 2024 15:15:06 +0300 Subject: [PATCH 3/5] Reverse logic --- src/main/java/io/jenkins/plugins/jfrog/JfStep.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/jenkins/plugins/jfrog/JfStep.java b/src/main/java/io/jenkins/plugins/jfrog/JfStep.java index ad57b4b0..21c8da6b 100644 --- a/src/main/java/io/jenkins/plugins/jfrog/JfStep.java +++ b/src/main/java/io/jenkins/plugins/jfrog/JfStep.java @@ -11,7 +11,6 @@ import hudson.model.Job; import hudson.model.Run; import hudson.model.TaskListener; -import hudson.model.FreeStyleProject; import hudson.tasks.BuildStepDescriptor; import hudson.tasks.Builder; import hudson.util.ArgumentListBuilder; @@ -27,6 +26,7 @@ import org.apache.commons.lang3.exception.ExceptionUtils; import org.jenkinsci.Symbol; import org.jenkinsci.plugins.plaincredentials.StringCredentials; +import org.jenkinsci.plugins.workflow.job.WorkflowJobProperty; import org.jfrog.build.api.util.Log; import org.kohsuke.stapler.DataBoundConstructor; @@ -292,8 +292,9 @@ public String getDisplayName() { @Override public boolean isApplicable(Class jobType) { - // Return false to hide it in Freestyle jobs - return !FreeStyleProject.class.isAssignableFrom(jobType); + // Ensure this is only applicable to Freestyle projects to avoid confusion + // when used in other project types, as it extends SimpleBuildStep. + return WorkflowJobProperty.class.isAssignableFrom(jobType); } } } From 953f14ee95ba3e6eb3ddce2a4cd82e33c59439f1 Mon Sep 17 00:00:00 2001 From: delarea Date: Mon, 9 Sep 2024 15:23:54 +0300 Subject: [PATCH 4/5] Rephrase comments --- src/main/java/io/jenkins/plugins/jfrog/JfStep.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/jenkins/plugins/jfrog/JfStep.java b/src/main/java/io/jenkins/plugins/jfrog/JfStep.java index 21c8da6b..bc13b58e 100644 --- a/src/main/java/io/jenkins/plugins/jfrog/JfStep.java +++ b/src/main/java/io/jenkins/plugins/jfrog/JfStep.java @@ -292,8 +292,9 @@ public String getDisplayName() { @Override public boolean isApplicable(Class jobType) { - // Ensure this is only applicable to Freestyle projects to avoid confusion - // when used in other project types, as it extends SimpleBuildStep. + // JfStep Extends SimpleBuildStep, which applies also to FreeStyleProjects, as well as workflow jobs. + // To avoid errors due to unsupported inputs in FreeStyleProjects, + // Return applicable only for WorkflowJobProperty. return WorkflowJobProperty.class.isAssignableFrom(jobType); } } From 6397a65b22fb59f15f1e66c32bde93330355e666 Mon Sep 17 00:00:00 2001 From: delarea Date: Thu, 12 Sep 2024 11:47:11 +0300 Subject: [PATCH 5/5] edit comments --- src/main/java/io/jenkins/plugins/jfrog/JfStep.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/jenkins/plugins/jfrog/JfStep.java b/src/main/java/io/jenkins/plugins/jfrog/JfStep.java index bc13b58e..929814ff 100644 --- a/src/main/java/io/jenkins/plugins/jfrog/JfStep.java +++ b/src/main/java/io/jenkins/plugins/jfrog/JfStep.java @@ -293,7 +293,7 @@ public String getDisplayName() { @Override public boolean isApplicable(Class jobType) { // JfStep Extends SimpleBuildStep, which applies also to FreeStyleProjects, as well as workflow jobs. - // To avoid errors due to unsupported inputs in FreeStyleProjects, + // To avoid errors due to unsupported inputs in non-Pipelines job types. // Return applicable only for WorkflowJobProperty. return WorkflowJobProperty.class.isAssignableFrom(jobType); }