Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #5 from lemmy/master
JENKINS-15395 - Add checkbox to run script when build fails
  • Loading branch information
gboissinot committed Mar 6, 2013
2 parents 2a728e8 + e1f5c60 commit bc2ecc1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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> {

Expand Down
Expand Up @@ -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 bc2ecc1

Please sign in to comment.