package notifier;
import hudson.Extension;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.BuildListener;
import hudson.tasks.*;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
/**
* Created by giladba on 8/31/2015.
*/
public class BuildNotifier extends Notifier {
private final String to;
@DataBoundConstructor
public BuildNotifier(String to){
if(to==null)
to="";
this.to=to;
}
@Override
public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) {
// build.getEnvVars()["myVar"]
// listener.getLogger().println("Build Success Notifier Finished.");
return true;
}
@Override
public BuildStepMonitor getRequiredMonitorService() {
return null;
}
public String getTo() {
return to;
}
@Override
public DescriptorImpl getDescriptor() {
return (DescriptorImpl)super.getDescriptor();
}
@Extension
public static final class DescriptorImpl extends BuildStepDescriptor<Publisher> {
public DescriptorImpl() {
load();
}
@Override
public boolean isApplicable(Class<? extends AbstractProject> jobType) {
return true;
}
@Override
public boolean configure(StaplerRequest req, JSONObject formData) throws FormException {
save();
return super.configure(req,formData);
}
@Override
public String getDisplayName() {
return "Build Success Email";
}
}
}
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<!--
This jelly script is used for per-project configuration.
See global.jelly for a general discussion about jelly script.
-->
<!--
Creates a text field that shows the value of the "name" property.
When submitted, it will be passed to the corresponding constructor parameter.
-->
<f:entry title="To" field="to">
<f:textarea />
</f:entry>
</j:jelly>
/**
* Calls a build step.
*/
protected final boolean perform(BuildStep bs, BuildListener listener) throws InterruptedException, IOException {
BuildStepMonitor mon;
try {
mon = bs.getRequiredMonitorService();
} catch (AbstractMethodError e) {
mon = BuildStepMonitor.BUILD;
}
Result oldResult = AbstractBuild.this.getResult();
for (BuildStepListener bsl : BuildStepListener.all()) {
bsl.started(AbstractBuild.this, bs, listener);
}
boolean canContinue = mon.perform(bs, AbstractBuild.this, launcher, listener);
Solved my Slide-O-Mix, my mistake was that i returned null, it needs to be like this :
@Override
public BuildStepMonitor getRequiredMonitorService() {
return BuildStepMonitor.NONE;