Skip to content
Permalink
Browse files

JENKINS-15395

Add checkbox to run script when build fails
https://issues.jenkins-ci.org/browse/JENKINS-15395
  • Loading branch information
lemmy committed Mar 6, 2013
1 parent 2a728e8 commit e1f5c60fe99c70669df7fb57a24847f5cdf05630
@@ -37,18 +37,21 @@ public BuildStepMonitor getRequiredMonitorService() {
private List<BuildStep> buildSteps;

private boolean scriptOnlyIfSuccess;
private boolean scriptOnlyIfFailure;

@DataBoundConstructor
public PostBuildScript(List<GenericScript> genericScriptFile,
List<GroovyScriptFile> groovyScriptFile,
List<GroovyScriptContent> groovyScriptContent,
boolean scriptOnlyIfSuccess,
boolean scriptOnlyIfFailure,
List<BuildStep> buildStep) {
this.genericScriptFileList = genericScriptFile;
this.groovyScriptFileList = groovyScriptFile;
this.groovyScriptContentList = groovyScriptContent;
this.buildSteps = buildStep;
this.scriptOnlyIfSuccess = scriptOnlyIfSuccess;
this.scriptOnlyIfFailure = scriptOnlyIfFailure;
}

public MatrixAggregator createAggregator(MatrixBuild build, Launcher launcher, BuildListener listener) {
@@ -81,6 +84,9 @@ private boolean _perform(AbstractBuild<?, ?> build, final Launcher launcher, fin
if (scriptOnlyIfSuccess && build.getResult().isWorseThan(Result.SUCCESS)) {
listener.getLogger().println("[PostBuildScript] Build is not success : do not execute script");
return true;
} else if (scriptOnlyIfFailure && build.getResult().isBetterThan(Result.FAILURE)) {
listener.getLogger().println("[PostBuildScript] Build is not failure : do not execute script");
return true;
} else {
return processScripts(executor, build, launcher, listener);
}
@@ -256,6 +262,11 @@ public boolean isScriptOnlyIfSuccess() {
return scriptOnlyIfSuccess;
}

@SuppressWarnings("unused")
public boolean isScriptOnlyIfFailure() {
return scriptOnlyIfFailure;
}

@Extension(ordinal = 99)
public static class DescriptorImpl extends BuildStepDescriptor<Publisher> {

@@ -93,5 +93,9 @@
<f:entry title="${%Execute script only if build succeeds}">
<f:checkbox name="scriptOnlyIfSuccess" checked="${h.defaultToTrue(instance.scriptOnlyIfSuccess)}"/>
</f:entry>

<f:entry title="${%Execute script only if build fails}">
<f:checkbox name="scriptOnlyIfFailure" checked="${h.defaultToFalse(instance.scriptOnlyIfFailure)}"/>
</f:entry>

</j:jelly>

0 comments on commit e1f5c60

Please sign in to comment.
You can’t perform that action at this time.