Skip to content

Commit

Permalink
Add option to fail the build if the Code Dx analysis failed (#12)
Browse files Browse the repository at this point in the history
* Add option to fail the build if the Code Dx analysis failed

* Remove unnecessary import
  • Loading branch information
tylercamp committed Jan 11, 2023
1 parent be9d58c commit e651418
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
Expand Up @@ -29,17 +29,20 @@ public class AnalysisResultConfiguration {
private boolean failureOnlyNew;
private boolean unstableOnlyNew;
private int numBuildsInGraph;

private boolean breakIfFailed;

@DataBoundConstructor
public AnalysisResultConfiguration(String failureSeverity,
String unstableSeverity, boolean failureOnlyNew,
boolean unstableOnlyNew, int numBuildsInGraph) {
boolean unstableOnlyNew, int numBuildsInGraph,
boolean breakIfFailed) {

this.failureSeverity = failureSeverity;
this.unstableSeverity = unstableSeverity;
this.failureOnlyNew = failureOnlyNew;
this.unstableOnlyNew = unstableOnlyNew;
this.numBuildsInGraph = numBuildsInGraph;
this.breakIfFailed = breakIfFailed;
}
public String getFailureSeverity() {
return failureSeverity;
Expand Down Expand Up @@ -71,4 +74,10 @@ public int getNumBuildsInGraph() {
public void setNumBuildsInGraph(int numBuildsInGraph) {
this.numBuildsInGraph = numBuildsInGraph;
}
public boolean getBreakIfFailed() {
return breakIfFailed;
}
public void setBreakIfFailed(boolean breakIfFailed) {
this.breakIfFailed = breakIfFailed;
}
}
Expand Up @@ -451,6 +451,9 @@ public void perform(
}
} else {
buildOutput.println("Analysis status: " + status);
if (analysisResultConfiguration.getBreakIfFailed()) {
throw new AbortException("Code Dx analysis ended with status '" + status + "' instead of '" + Job.COMPLETED + "', terminating build");
}
}
} finally {
if(sourceAndBinaryZip != null){
Expand Down
Expand Up @@ -50,6 +50,10 @@
<f:optionalBlock title="Wait for Analysis Results" name="analysisResultConfiguration" checked="${analysisResultConfiguration != null}" help="/plugin/codedx/help-analysisResultConfiguration.html">

<f:section title="Build Failure Conditions">
<f:entry title="Analysis Error" field="breakIfFailed" help="/plugin/codedx/help-breakIfFailed.html">
<f:checkbox checked="${analysisResultConfiguration.breakIfFailed}" default="true" />
</f:entry>

<f:entry title="Severity" field="failureSeverity" help="/plugin/codedx/help-failureSeverity.html">
<f:select value="${analysisResultConfiguration.failureSeverity}"/>
</f:entry>
Expand Down
4 changes: 4 additions & 0 deletions src/main/webapp/help-breakIfFailed.html
@@ -0,0 +1,4 @@
<div>
<p>Whether or not to fail the build if the Code Dx analysis fails.</p>
<p>Note: connection errors such as timeouts will cause the build to fail regardless of this setting.</p>
</div>

0 comments on commit e651418

Please sign in to comment.