aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-09-11 02:06:10 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-09-11 02:12:12 +0300
commit4a5aa4699c4e6911921e00fa80495dac60d984c3 (patch)
treed6d9781d742b5844504dc4a71a8678334b655083 /src/main/java
parent7f1991d86130b9f5242c1c7c4ab4122130922462 (diff)
Plugin skeleton which implements basic build step and configuration.
What remains is actual requesting of one-time token. Change-Id: I30c765405f2e6d37cdfe28dccbf3db6a23d5f552
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/linaro/pubapi/LinaroPubAPIKey.java75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/main/java/linaro/pubapi/LinaroPubAPIKey.java b/src/main/java/linaro/pubapi/LinaroPubAPIKey.java
new file mode 100644
index 0000000..0c3415b
--- /dev/null
+++ b/src/main/java/linaro/pubapi/LinaroPubAPIKey.java
@@ -0,0 +1,75 @@
+package linaro.pubapi;
+
+import hudson.Extension;
+import hudson.Launcher;
+import hudson.model.AbstractBuild;
+import hudson.model.AbstractProject;
+import hudson.model.BuildListener;
+import hudson.model.FreeStyleProject;
+import hudson.model.ParametersAction;
+import hudson.model.StringParameterValue;
+import hudson.tasks.BuildStepDescriptor;
+import hudson.tasks.Builder;
+
+import org.kohsuke.stapler.DataBoundConstructor;
+import org.kohsuke.stapler.StaplerRequest;
+
+import net.sf.json.JSONObject;
+
+/**
+ * @author Paul Sokolovsky
+ */
+public class LinaroPubAPIKey extends Builder {
+
+ @DataBoundConstructor
+ public LinaroPubAPIKey() {
+ }
+
+
+ @Override
+ public Descriptor getDescriptor() {
+ return (Descriptor) super.getDescriptor();
+ }
+
+ @Extension
+ public static class Descriptor extends BuildStepDescriptor<Builder> {
+
+ private String secretKey;
+
+ public Descriptor() {
+ load();
+ }
+
+ public String getPubAPISecretKey() {
+ return secretKey;
+ }
+
+ public void setPubAPISecretKey(String secretKey) {
+ this.secretKey = secretKey;
+ }
+
+ @Override
+ public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
+ req.bindJSON(this, json.getJSONObject("linaropubapi"));
+ save();
+ return true;
+ }
+
+ @Override
+ public boolean isApplicable(Class<? extends AbstractProject> jobType) {
+ return FreeStyleProject.class.isAssignableFrom(jobType);
+ }
+
+ @Override
+ public String getDisplayName() {
+ return "Linaro Publishing API Token";
+ }
+
+ }
+
+ @Override
+ public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws InterruptedException {
+ build.addAction(new ParametersAction(new StringParameterValue("PUBKEY", getDescriptor().getPubAPISecretKey() + "XXX")));
+ return true;
+ }
+}