Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from svanoort/disable-pipeline-resume-JENKINS-…
…33761 Provide job property for durability hints & add ability to disable pipeline resume [JENKINS-33761]
- Loading branch information
Showing
12 changed files
with
486 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/org/jenkinsci/plugins/workflow/job/properties/DisableResumeJobProperty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.jenkinsci.plugins.workflow.job.properties; | ||
|
||
import hudson.Extension; | ||
import hudson.model.Item; | ||
import jenkins.model.OptionalJobProperty; | ||
import org.jenkinsci.Symbol; | ||
import org.jenkinsci.plugins.workflow.flow.DurabilityHintProvider; | ||
import org.jenkinsci.plugins.workflow.flow.FlowDurabilityHint; | ||
import org.jenkinsci.plugins.workflow.job.WorkflowJob; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
import javax.annotation.CheckForNull; | ||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
* Disables resuming a pipeline if the master restarts - the run will simply fail instead, just like a FreeStyle job. | ||
* @author Sam Van Oort | ||
*/ | ||
public class DisableResumeJobProperty extends OptionalJobProperty<WorkflowJob> { | ||
@DataBoundConstructor | ||
public DisableResumeJobProperty(){ } | ||
|
||
@Extension | ||
@Symbol("disableResume") | ||
public static class DescriptorImpl extends OptionalJobPropertyDescriptor implements DurabilityHintProvider{ | ||
|
||
@Override public String getDisplayName() { | ||
return "Do not allow the pipeline to resume if the master restarts."; | ||
} | ||
|
||
@Override | ||
public int ordinal() { | ||
return 50; | ||
} | ||
|
||
@CheckForNull | ||
@Override | ||
public FlowDurabilityHint suggestFor(@Nonnull Item x) { | ||
if (x instanceof WorkflowJob) { | ||
DisableResumeJobProperty prop = ((WorkflowJob) x).getProperty(DisableResumeJobProperty.class); | ||
return (prop != null) ? FlowDurabilityHint.PERFORMANCE_OPTIMIZED : null; | ||
} | ||
return null; | ||
} | ||
} | ||
} |
Oops, something went wrong.