Skip to content

Commit

Permalink
Merge pull request #282 from Vlatombe/defend-against-corrupt-builds
Browse files Browse the repository at this point in the history
Defending against corrupt builds
  • Loading branch information
jglick authored Mar 14, 2024
2 parents 8379294 + cb9166f commit 67474e5
Showing 1 changed file with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -367,20 +367,24 @@ static TestResult getTestResult(Job<?, ?> originProject, Run<?, ?> b, TaskListen
for (int i = 0; i < NUMBER_OF_BUILDS_TO_SEARCH; i++) {// limit the search to a small number to avoid loading too much
if (b == null) break;
if (RESULTS_OF_BUILDS_TO_CONSIDER.contains(b.getResult()) && !b.isBuilding()) {
AbstractTestResultAction tra = b.getAction(AbstractTestResultAction.class);
if (tra != null) {
Object o = tra.getResult();
if (o instanceof TestResult) {
TestResult tr = (TestResult) o;
String hyperlink = ModelHyperlinkNote.encodeTo('/' + b.getUrl(), originProject != b.getParent() ? b.getFullDisplayName() : b.getDisplayName());
if (tr.getTotalCount() == 0) {
listener.getLogger().printf("Build %s has no loadable test results (supposed count %d), skipping%n", hyperlink, tra.getTotalCount());
} else {
listener.getLogger().printf("Using build %s as reference%n", hyperlink);
result = tr;
break;
String hyperlink = ModelHyperlinkNote.encodeTo('/' + b.getUrl(), originProject != b.getParent() ? b.getFullDisplayName() : b.getDisplayName());

Check warning on line 370 in src/main/java/org/jenkinsci/plugins/parallel_test_executor/ParallelTestExecutor.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 370 is only partially covered, one branch is missing
try {
AbstractTestResultAction tra = b.getAction(AbstractTestResultAction.class);
if (tra != null) {
Object o = tra.getResult();
if (o instanceof TestResult) {
TestResult tr = (TestResult) o;
if (tr.getTotalCount() == 0) {
listener.getLogger().printf("Build %s has no loadable test results (supposed count %d), skipping%n", hyperlink, tra.getTotalCount());
} else {
listener.getLogger().printf("Using build %s as reference%n", hyperlink);
result = tr;
break;
}
}
}
} catch (RuntimeException e) {
e.printStackTrace(listener.error("Failed to load (corrupt?) build %s, skipping%n", hyperlink));

Check warning on line 387 in src/main/java/org/jenkinsci/plugins/parallel_test_executor/ParallelTestExecutor.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 386-387 are not covered by tests
}
}
b = b.getPreviousBuild();
Expand Down

0 comments on commit 67474e5

Please sign in to comment.