I created this class 

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";
        }
    }

}



and added a config.jelly but when i run a build with that step i get this:

java.lang.NullPointerException
at 
hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:770)
at 
hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:734)
at hudson.model.Build$BuildExecution.post2(Build.java:183)
at 
hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:683)
at hudson.model.Run.execute(Run.java:1770)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:89)
at hudson.model.Executor.run(Executor.java:240)

please help

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/17aa6ef9-dff4-49c0-b7fa-aaca34cc0e45%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to