Skip to content

Commit

Permalink
Merge pull request #55 from mbarrien/pipeline
Browse files Browse the repository at this point in the history
JENKINS-30700 / #50 Jenkins pipeline support
  • Loading branch information
mbarrien committed Apr 25, 2017
2 parents 75d7da7 + 4cdc216 commit 681d24c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
14 changes: 11 additions & 3 deletions src/main/java/hudson/plugins/cobertura/CoberturaPublisher.java
Expand Up @@ -385,6 +385,13 @@ public void perform(Run<?, ?> build, FilePath workspace, Launcher launcher, fina
FilePath[] reports = null;
try {
reports = workspace.act(new ParseReportCallable(coberturaReportFile));

// if the build has failed, then there's not
// much point in reporting an error
if (buildResult != null && buildResult.isWorseOrEqualTo(Result.FAILURE) && reports.length == 0) {
return;
}

} catch (IOException e) {
Util.displayIOException(e, listener);
e.printStackTrace(listener.fatalError("Unable to find coverage results"));
Expand Down Expand Up @@ -694,9 +701,10 @@ public boolean configure(StaplerRequest req, JSONObject formData) throws FormExc
*/
@Override
public CoberturaPublisher newInstance(StaplerRequest req, JSONObject formData) throws FormException {
if (req == null) {
return null;
}
// Null check because findbugs insists, despite the API guaranteeing this is never null.
if (req == null) {
throw new FormException("req cannot be null", "");
}
CoberturaPublisher instance = req.bindJSON(CoberturaPublisher.class, formData);
ConvertUtils.register(CoberturaPublisherTarget.CONVERTER, CoverageMetric.class);
List<CoberturaPublisherTarget> targets = req
Expand Down
Expand Up @@ -106,13 +106,12 @@ public Map<CoverageMetric, Integer> getRangeScores(CoverageTarget min, CoverageR
}

public Map<CoverageMetric, Integer> getRangeScores(CoverageTarget min, Map<CoverageMetric, Ratio> results) {
Integer j;
Map<CoverageMetric, Integer> result = new EnumMap<CoverageMetric, Integer>(CoverageMetric.class);
for (Map.Entry<CoverageMetric, Integer> target : this.targets.entrySet()) {
Ratio observed = results.get(target.getKey());
if (observed != null) {
j = CoverageTarget.calcRangeScore(target.getValue() / 100000, min.targets.get(target.getKey()), observed.getPercentage());
result.put(target.getKey(), j);
int j = CoverageTarget.calcRangeScore(target.getValue() / 100000, min.targets.get(target.getKey()), observed.getPercentage());
result.put(target.getKey(), Integer.valueOf(j));
}
}
return result;
Expand Down

0 comments on commit 681d24c

Please sign in to comment.