aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Sokolovsky <paul.sokolovsky@linaro.org>2015-10-23 19:10:25 +0300
committerPaul Sokolovsky <paul.sokolovsky@linaro.org>2015-10-23 19:10:25 +0300
commit6ffc1ff4a3e89e5c4a19dc85dcbbf2e21a4f9115 (patch)
treeb205fc4c4c41ec1326268f768b57d9fcef7446d1
parent8db0db4dbf0d560fd2b8a325a39a039ec8a38f87 (diff)
downloadjenkins-plugin-linaro-pubapi-master.tar.gz
Make own class for publishing params, and replace them on each invocation.HEADmaster
Replacing parameters on each invocation of build step is required to support requesting tokens from multiple servers in row to support complex publishing scenarios. Having a separate Java class for paramters is a pre-requisite for such replacing. AbstractBuild.replaceAction also requires fairly recent Jenkins core, so just bump dependency version to the current LTS we use. Change-Id: I01de367d0db22bcd0fd43476894a5d072161ac03
-rw-r--r--pom.xml4
-rw-r--r--src/main/java/linaro/pubapi/LinaroPubAPIKey.java2
-rw-r--r--src/main/java/linaro/pubapi/LinaroPubTokenAction.java33
3 files changed, 36 insertions, 3 deletions
diff --git a/pom.xml b/pom.xml
index 7d0e29c..34b5d6d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,13 +4,13 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
- <version>1.445</version>
+ <version>1.609.3</version>
</parent>
<artifactId>linaro-pubapi</artifactId>
<packaging>hpi</packaging>
<name>Linaro Publishing API Token Plugin</name>
- <version>1.2.1</version>
+ <version>1.3</version>
<url>https://wiki.jenkins-ci.org/display/JENKINS/Plugins</url>
<repositories>
diff --git a/src/main/java/linaro/pubapi/LinaroPubAPIKey.java b/src/main/java/linaro/pubapi/LinaroPubAPIKey.java
index ca91ac3..3f85f80 100644
--- a/src/main/java/linaro/pubapi/LinaroPubAPIKey.java
+++ b/src/main/java/linaro/pubapi/LinaroPubAPIKey.java
@@ -181,7 +181,7 @@ public class LinaroPubAPIKey extends Builder {
params.add(new StringParameterValue("PUBLISH_SERVER", serverUrl));
}
- build.addAction(new ParametersAction(params));
+ build.replaceAction(new LinaroPubTokenAction(params));
return true;
}
diff --git a/src/main/java/linaro/pubapi/LinaroPubTokenAction.java b/src/main/java/linaro/pubapi/LinaroPubTokenAction.java
new file mode 100644
index 0000000..b8d01de
--- /dev/null
+++ b/src/main/java/linaro/pubapi/LinaroPubTokenAction.java
@@ -0,0 +1,33 @@
+package linaro.pubapi;
+
+import java.util.List;
+import org.kohsuke.stapler.export.ExportedBean;
+import hudson.model.ParametersAction;
+import hudson.model.ParameterValue;
+
+// We need a separate class for our parameters to be to able
+// easily replace older param instance in case "get token"
+// build steps is used more than once in a build (which is
+// an extended requirements from Builds&Baselines). And Jenkins
+// distinguishes various types of params by a class. However,
+// in some places, Jenkins also makes subclass checks, so
+// there's no complete warranty this won't interfere with
+// standard build params (as represented by ParametersAction).
+// Still, it's good improvement over previous verison which just
+// reused ParametersAction without any guards.
+
+@ExportedBean
+public class LinaroPubTokenAction extends ParametersAction {
+
+ public LinaroPubTokenAction(List<ParameterValue> parameters) {
+ super(parameters);
+ }
+
+ public String getDisplayName() {
+ return "Linaro PubAPI";
+ }
+
+ public String getUrlName() {
+ return "linaropub";
+ }
+}