Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public class TriggerStep extends AbstractStepImpl {
private final String spec;
public TriggerStep(String spec) {
this.spec = spec;
public String getSpec() {
return spec;
public static class Execution extends AbstractSynchronousStepExecution<Void> {
private static final long serialVersionUID = 1L;
transient TriggerStep step;
transient Run<?,?> build;
protected Void run() throws Exception {
Job<?,?> parent = build.getParent();
if(parent instanceof WorkflowJob) {
WorkflowJob job = (WorkflowJob) parent;
job.addTrigger(new SCMTrigger(step.getSpec()));;
} else {
throw new AbortException("cannot apply trigger to job of type " + parent.getClass().getSimpleName());
return null;
public static class DiscriptorImpl extends AbstractStepDescriptorImpl {
public DiscriptorImpl() {
public String getFunctionName() {
return "scmTrigger";
public String getDisplayName() {
return "Set an SCM Trigger for this project.";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment