Search in sources :

Example 1 with PipelineTriggersJobProperty

use of org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty in project workflow-job-plugin by jenkinsci.

the class WorkflowJob method addTrigger.

public void addTrigger(Trigger trigger) throws IOException {
    BulkChange bc = new BulkChange(this);
    try {
        PipelineTriggersJobProperty originalProp = getTriggersJobProperty();
        Trigger old = originalProp.getTriggerForDescriptor(trigger.getDescriptor());
        if (old != null) {
            originalProp.removeTrigger(old);
            old.stop();
        }
        originalProp.addTrigger(trigger);
        removeProperty(PipelineTriggersJobProperty.class);
        addProperty(originalProp);
        bc.commit();
    } finally {
        bc.abort();
    }
}
Also used : Trigger(hudson.triggers.Trigger) SCMTrigger(hudson.triggers.SCMTrigger) BulkChange(hudson.BulkChange) PipelineTriggersJobProperty(org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty)

Example 2 with PipelineTriggersJobProperty

use of org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty in project workflow-job-plugin by jenkinsci.

the class WorkflowJob method setTriggers.

public void setTriggers(List<Trigger<?>> inputTriggers) throws IOException {
    triggers = null;
    BulkChange bc = new BulkChange(this);
    try {
        PipelineTriggersJobProperty originalProp = getTriggersJobProperty();
        removeProperty(PipelineTriggersJobProperty.class);
        PipelineTriggersJobProperty triggerProp = new PipelineTriggersJobProperty(null);
        triggerProp.setTriggers(inputTriggers);
        addProperty(triggerProp);
        bc.commit();
        originalProp.stopTriggers();
    // No longer need to start triggers here - that's done by when we add the property.
    } finally {
        bc.abort();
    }
}
Also used : BulkChange(hudson.BulkChange) PipelineTriggersJobProperty(org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty)

Aggregations

BulkChange (hudson.BulkChange)2 PipelineTriggersJobProperty (org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty)2 SCMTrigger (hudson.triggers.SCMTrigger)1 Trigger (hudson.triggers.Trigger)1