Skip to content

Add support for retrying a build after a node restart #3271

Merged
uhafner merged 7 commits intojenkinsci:mainfrom
akash-manna-sky:JENKINS-72920
Apr 17, 2026
Merged

Add support for retrying a build after a node restart #3271
uhafner merged 7 commits intojenkinsci:mainfrom
akash-manna-sky:JENKINS-72920

Conversation

@akash-manna-sky
Copy link
Copy Markdown
Contributor

@akash-manna-sky akash-manna-sky commented Feb 13, 2026

When Jenkins retries a build after a restart there might be already a published action available. In such a case we should not fail the build, we should only log a warning.

Fixes #3138

Testing done

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

…ady used by another action: io.jenkins.plugins.analysis.core.model.ResultAction for SpotBugs
@akash-manna-sky akash-manna-sky marked this pull request as ready for review February 13, 2026 19:25
@akash-manna-sky
Copy link
Copy Markdown
Contributor Author

Please review the changes @uhafner

@github-actions github-actions bot requested a review from uhafner April 12, 2026 08:59
@github-actions
Copy link
Copy Markdown

☀️   Quality Monitor

Tests

   JUnit   Unit Tests: ✅ successful — 93 passed, 2 skipped
   🚀   Integration Tests: ✅ successful — 507 passed, 10 skipped
   ⛔   Architecture Tests: ✅ successful — 15 passed

Coverage for New Code

   〰️   Line Coverage: 100.00% — perfect 🎉
   ➰   Branch Coverage: 100.00% — perfect 🎉

Coverage for Whole Project

   〰️   Line Coverage: 80.78% — 1176 missed lines
   ➰   Branch Coverage: 64.76% — 468 missed branches

Style

   CheckStyle   CheckStyle: No warnings
   PMD   PMD: No warnings
   ☕   Java Compiler: 97 warnings — normal: 97

Bugs

   SpotBugs   SpotBugs: No bugs
   🐛   Error Prone: 9 bugs — normal: 9

Vulnerabilities

   🛡️   OWASP Dependency Check: 214 vulnerabilities — error: 18, high: 54, normal: 136, low: 6

Software Metrics

   🌀   Cyclomatic Complexity: 2603 (total)
   💭   Cognitive Complexity: 835 (total)
   ➿   N-Path Complexity: 2954 (total)
   📏   Lines of Code: 31810 (total)
   📝   Non Commenting Source Statements: 10586 (total)
   🔗   Class Cohesion: 100.00% (maximum)
   ⚖️   Weight of Class: 100.00% (maximum)

🚦 Quality Gates

Overall Status: ❌ FAILURE

✅ Passed Gates

  • ✅ Overall Tests Success Rate: 100.00 >= 100.00
  • ✅ Line Coverage in New Code: 100.00 >= 90.00
  • ✅ Branch Coverage in New Code: 100.00 >= 90.00

❌ Failed Gates

  • ❌ Potential Bugs in Whole Project: 9.00 <= 0.00
  • ❌ Style Violation in Whole Project: 97.00 <= 0.00

Created by Quality Monitor v4.10.0 (#be1b382). More details are shown in the GitHub Checks Result.

Copy link
Copy Markdown
Member

@uhafner uhafner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you attach the action with run.addOrReplaceAction

if (other.isPresent()) {
throw new IllegalStateException(
"ID %s is already used by another action: %s%n".formatted(getId(), other.get()));
report.logInfo("Removing existing result action with ID '%s' (might be caused by a restart)", getId());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
report.logInfo("Removing existing result action with ID '%s' (might be caused by a restart)", getId());
report.logError("Removing existing result action with ID '%s' (duplicate ID: restart or configuration error?)", getId());

Copy link
Copy Markdown
Member

@uhafner uhafner Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this method? It makes no sense anymore. Create the selector inline where it is needed.

See line 127.

List<AnalysisResult> results = getAnalysisResults(build);

assertThat(results).hasSize(1);
var result = results.get(0);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check the content of the warnings, so we can see that the second result is used? (Or remove one warning from the second file, then check for 5 issues.)

Comment on lines +380 to +402
/**
* Tests retry after restart scenario (JENKINS-72920). When the same tool is run twice within a build
* (which can happen during retry after infrastructure failure), the second run should replace the first
* with a warning message instead of throwing an exception.
*/
@Test
@org.junitpioneer.jupiter.Issue("JENKINS-72920")
void shouldAllowRetryAfterRestart() {
var project = createFreestyleJob("checkstyle.xml");
var tool = createTool(new CheckStyle(), "**/checkstyle-issues.txt");
enableWarnings(project, recorder -> recorder.setAggregatingResults(false), tool, tool);

Run<?, ?> build = buildWithResult(project, Result.SUCCESS);

List<AnalysisResult> results = getAnalysisResults(build);
assertThat(results).hasSize(1);

var result = results.get(0);
assertThat(result).hasId(CHECKSTYLE);
assertThat(result).hasTotalSize(6);
assertThat(getConsoleLog(result)).contains("Removing existing result action with ID 'checkstyle' (might be caused by a restart)");
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same test as shouldThrowExceptionIfSameToolIsConfiguredTwice. Remove it.

* be replaced with a warning (to support retry after restart scenarios).
*/
@Test
void shouldThrowExceptionIfSameToolIsConfiguredTwice() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void shouldThrowExceptionIfSameToolIsConfiguredTwice() {
void shouldReplaceExistingAction() {

@uhafner uhafner added the bug Bugs or performance problems label Apr 16, 2026
@github-actions github-actions bot requested a review from uhafner April 16, 2026 10:55
@akash-manna-sky
Copy link
Copy Markdown
Contributor Author

Can you please review the changes? @uhafner

Copy link
Copy Markdown
Member

@uhafner uhafner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Comment thread plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/IssuesPublisher.java Outdated
@github-actions github-actions bot requested a review from uhafner April 16, 2026 20:27
@uhafner uhafner changed the title Retry after restart causes IllegalStateException: ID spotbugs is already used by another action: io.jenkins.plugins.analysis.core.model.ResultAction for SpotBugs Add support for retrying a build after a node restart Apr 17, 2026
@uhafner uhafner merged commit 94ad6ca into jenkinsci:main Apr 17, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Bugs or performance problems

Projects

None yet

2 participants