From 909f0a6ba8ab362f9114df7cfac428839e697418 Mon Sep 17 00:00:00 2001 From: Jo Shields Date: Thu, 23 Jul 2015 09:21:15 +0100 Subject: [PATCH 1/2] Handle null BuildSelector (Closes: JENKINS-29582) This drops use of ca:selectorList (removed in copyartifact-1.35.1), and adds a fallback to StatusBuildSelector in the event of a bad BuildSelector being passed from jelly (a similar fallback exists in copyartifact) --- .../hudson/plugins/s3/S3CopyArtifact.java | 10 ++- .../hudson/plugins/s3/S3CopyArtifact.stapler | 2 - .../plugins/s3/S3CopyArtifact/config.jelly | 6 +- .../hudson/plugins/s3/selectorList.jelly | 67 ------------------- 4 files changed, 11 insertions(+), 74 deletions(-) delete mode 100644 src/main/resources/hudson/plugins/s3/S3CopyArtifact.stapler delete mode 100644 src/main/resources/hudson/plugins/s3/selectorList.jelly diff --git a/src/main/java/hudson/plugins/s3/S3CopyArtifact.java b/src/main/java/hudson/plugins/s3/S3CopyArtifact.java index 55fd8169..86eb9a33 100644 --- a/src/main/java/hudson/plugins/s3/S3CopyArtifact.java +++ b/src/main/java/hudson/plugins/s3/S3CopyArtifact.java @@ -59,6 +59,7 @@ import hudson.plugins.copyartifact.Messages; import hudson.plugins.copyartifact.ParametersBuildFilter; import hudson.plugins.copyartifact.WorkspaceSelector; +import hudson.plugins.copyartifact.StatusBuildSelector; import hudson.security.AccessControlled; import hudson.security.SecurityRealm; import hudson.tasks.BuildStepDescriptor; @@ -101,16 +102,21 @@ public class S3CopyArtifact extends Builder { private final String filter, target; private /*almost final*/ BuildSelector selector; private final Boolean flatten, optional; + + private static final BuildSelector DEFAULT_BUILD_SELECTOR = new StatusBuildSelector(true); @DataBoundConstructor - public S3CopyArtifact(String projectName, BuildSelector selector, String filter, String target, + public S3CopyArtifact(String projectName, BuildSelector buildSelector, String filter, String target, boolean flatten, boolean optional) { // Prevents both invalid values and access to artifacts of projects which this user cannot see. // If value is parameterized, it will be checked when build runs. if (projectName.indexOf('$') < 0 && new JobResolver(projectName).job == null) projectName = ""; // Ignore/clear bad value to avoid ugly 500 page this.projectName = projectName; - this.selector = selector; + if (buildSelector == null) { + buildSelector = DEFAULT_BUILD_SELECTOR; + } + this.selector = buildSelector; this.filter = Util.fixNull(filter).trim(); this.target = Util.fixNull(target).trim(); this.flatten = flatten ? Boolean.TRUE : null; diff --git a/src/main/resources/hudson/plugins/s3/S3CopyArtifact.stapler b/src/main/resources/hudson/plugins/s3/S3CopyArtifact.stapler deleted file mode 100644 index c8231330..00000000 --- a/src/main/resources/hudson/plugins/s3/S3CopyArtifact.stapler +++ /dev/null @@ -1,2 +0,0 @@ -#Thu Jan 12 13:32:19 PST 2012 -constructor=projectName,selector,filter,target,flatten,optional diff --git a/src/main/resources/hudson/plugins/s3/S3CopyArtifact/config.jelly b/src/main/resources/hudson/plugins/s3/S3CopyArtifact/config.jelly index c84ae284..1d0b766b 100644 --- a/src/main/resources/hudson/plugins/s3/S3CopyArtifact/config.jelly +++ b/src/main/resources/hudson/plugins/s3/S3CopyArtifact/config.jelly @@ -1,10 +1,10 @@ - + - + diff --git a/src/main/resources/hudson/plugins/s3/selectorList.jelly b/src/main/resources/hudson/plugins/s3/selectorList.jelly deleted file mode 100644 index f3019b97..00000000 --- a/src/main/resources/hudson/plugins/s3/selectorList.jelly +++ /dev/null @@ -1,67 +0,0 @@ - - - - - Generates a dropdown list with the available BuildSelectors. - - BuildSelector that is currently configured; form is populated showing this object. - - - Name for the form element. - - - Title for the form section. - - - Optional description for form section. - - - Provide the descriptor that has getBuildSelectors(), if not already in ${descriptor}. - - - Optional name of a selector type to omit from the list. - - - - - - - - - - - - - - - - - - - - From 7c04c98ff02ab3ab1ba2736f9308aac69b006957 Mon Sep 17 00:00:00 2001 From: Jo Shields Date: Thu, 30 Jul 2015 08:55:16 +0100 Subject: [PATCH 2/2] Build against new copyartifact ABI (no ca:selectorList) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 68519d85..fba6dc11 100644 --- a/pom.xml +++ b/pom.xml @@ -65,7 +65,7 @@ org.jenkins-ci.plugins copyartifact - 1.21 + 1.35.1 org.jenkins-ci.main