Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating a Jenkins Plugin which hooks into global build status' and has a global repeatable configuration?
    primarykey
    data
    text
    <p>I'm trying to create a supposedly simple Jenkins plugin which will communicate with a IP power strip device but I've run into a couple of problems. I've had a dig around the documentation but it seems to be sparse at best. </p> <p>My theory was to create a publisher with an associated descriptor. The descriptor would take in a repeatable form via a bean object (params) then make it available to the recorder. </p> <p>What actually seems to happen is: </p> <pre><code>Caused by: net.sf.json.JSONException: Error while setting property=data type interface java.util.List at net.sf.json.JSONObject.toBean(JSONObject.java:577) at net.sf.json.JSONObject.toBean(JSONObject.java:383) at net.sf.json.JSONObject.toBean(JSONObject.java:250) at hudson.tools.JDKInstaller$JDKList.toList(JDKInstaller.java:612) at hudson.tools.JDKInstaller$DescriptorImpl.getInstallableJDKs(JDKInstaller.java:588) ... 237 more Caused by: java.lang.NullPointerException at net.sf.json.JSONObject$MethodProperty.isWritable(JSONObject.java:311) at net.sf.json.JSONObject.toBean(JSONObject.java:429) ... 241 more </code></pre> <p>Here's the params class</p> <pre><code>package com.mb; import hudson.Extension; import hudson.model.AbstractDescribableImpl; import hudson.model.Descriptor; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.export.Exported; import org.kohsuke.stapler.export.ExportedBean; import java.io.Serializable; @ExportedBean public class PlugParamters extends AbstractDescribableImpl&lt;PlugParamters&gt; implements Serializable { private final String buildState; private final String plugId; private final int plugAction; @DataBoundConstructor public PlugParamters(String buildState, String plugId, int plugAction) { this.buildState = buildState; this.plugId = plugId; this.plugAction = plugAction; } @Exported public String getBuildState() { return buildState; } @Exported public String getPlugId() { return plugId; } @Exported public int getPlugAction() { return plugAction; } @Extension public static class DescriptorImpl extends Descriptor&lt;PlugParamters&gt; { public DescriptorImpl() { super(PlugParamters.class); } @Override public String getDisplayName() { return ""; } } } </code></pre> <p>and finally:</p> <pre><code>package com.mb; import hudson.Extension; import hudson.Launcher; import hudson.model.*; import hudson.tasks.BuildStepDescriptor; import hudson.tasks.BuildStepMonitor; import hudson.tasks.Publisher; import hudson.tasks.Recorder; import hudson.util.FormValidation; import net.sf.json.JSONObject; import org.kohsuke.stapler.QueryParameter; import org.kohsuke.stapler.StaplerRequest; import javax.servlet.ServletException; import java.io.IOException; import java.util.ArrayList; import java.util.List; public class IPPowerPublisher extends Recorder { public IPPowerPublisher() { } @Override public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) { return true; } @Override public DescriptorImpl getDescriptor() { return (DescriptorImpl) super.getDescriptor(); } public BuildStepMonitor getRequiredMonitorService() { return BuildStepMonitor.NONE; } private boolean oneOrMoreBuildsFailing(List&lt;Project&gt; projects) { boolean oneOrMoreBuildsFailing = false; for (Project project : projects) { Result projectLatestBuildResult = project.getLastBuild().getResult(); if (!(projectLatestBuildResult.isBetterOrEqualTo(Result.SUCCESS) || !projectLatestBuildResult.equals(Result.NOT_BUILT))) { oneOrMoreBuildsFailing = true; break; } } return oneOrMoreBuildsFailing; } @Extension public final static class DescriptorImpl extends BuildStepDescriptor&lt;Publisher&gt; { public List&lt;PlugParamters&gt; getPlugParamters() { return plugParamters; } public void setPlugParamters(List&lt;PlugParamters&gt; plugParamters) { this.plugParamters = plugParamters; } private List&lt;PlugParamters&gt; plugParamters = new ArrayList&lt;PlugParamters&gt;(); private String host = ""; public FormValidation doCheckHost(@QueryParameter String value) throws IOException, ServletException { if (value != null &amp;&amp; value.length() == 0) return FormValidation.error("Please set a host name or IP address"); return FormValidation.ok(); } @Override public String getDisplayName() { return "Continuous Integration Feedback"; } @Override public boolean configure(StaplerRequest req, JSONObject formData) throws hudson.model.Descriptor.FormException { host = formData.getString("host"); //plugParamters = req.bindParametersToList(PlugParamters.class, ""); save(); return super.configure(req, formData); } public String getHost() { return host; } public void setHost(String host) { this.host = host; } @Override public boolean isApplicable(Class&lt;? extends AbstractProject&gt; jobType) { return true; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload