Skip to content
Permalink
Browse files
[JENKINS-22303] Should have option to not care about build failure st…
…atus

- Option to try to process the report files even if the build is not successful added to job configuration.
- If no file is matching the input pattern, no data are stored and the build is marked as failed.
  • Loading branch information
mixalturek committed Mar 30, 2014
1 parent 4f30bbf commit 38eedb0848fd345f84f8a0294c2111e4ed4b446f
Showing 2 changed files with 24 additions and 4 deletions.
@@ -46,13 +46,17 @@ public class SloccountPublisher extends Recorder implements Serializable {
*/
private final int numBuildsInGraph;

@DataBoundConstructor
/** Try to process the report files even if the build state is marked as failed. */
private final boolean ignoreBuildFailure;

@DataBoundConstructor
public SloccountPublisher(String pattern, String encoding,
int numBuildsInGraph){
int numBuildsInGraph, boolean ignoreBuildFailure){
super();
this.pattern = pattern;
this.encoding = encoding;
this.numBuildsInGraph = numBuildsInGraph;
this.ignoreBuildFailure = ignoreBuildFailure;
}

@Override
@@ -69,8 +73,13 @@ public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListene
PrintStream logger = listener.getLogger();

if (!canContinue(build.getResult())) {
logger.println("[SLOCCount] Skipping results publication since the build is not successful");
return true;
if(ignoreBuildFailure) {
logger.println("[SLOCCount] Trying to process the report files even if the build is not successful");
// Continue as usual
} else {
logger.println("[SLOCCount] Skipping results publication since the build is not successful");
return true;
}
}

SloccountParser parser = new SloccountParser(this.getRealEncoding(), this.getRealPattern(), logger);
@@ -89,6 +98,7 @@ public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListene
if (report.getSourceFiles().size() == 0) {
logger.format("[SLOCCount] No file is matching the input pattern: %s%n",
getRealPattern());
return false;
}

SloccountResult result = new SloccountResult(report.getStatistics(),
@@ -106,6 +116,7 @@ public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListene
return false;
}

logger.format("[SLOCCount] Report successfully processed and all data stored%n");
return true;
}

@@ -180,4 +191,8 @@ public String getEncoding() {
public int getNumBuildsInGraph() {
return numBuildsInGraph;
}

public boolean isIgnoreBuildFailure() {
return ignoreBuildFailure;
}
}
@@ -12,5 +12,10 @@
<f:entry title="${%Builds in graph}" description="${%description.numBuildsInGraph}">
<f:textbox name="numBuildsInGraph" value="${instance.numBuildsInGraph}"/>
</f:entry>

<f:entry>
<f:checkbox name="ignoreBuildFailure" checked="${instance.ignoreBuildFailure}"/>
<label for="ignoreBuildFailure">${%Try to process the report files even if the build is not successful}</label>
</f:entry>
</f:advanced>
</j:jelly>

0 comments on commit 38eedb0

Please sign in to comment.