Skip to content

Update a single InterruptedBuildAction rather than creating a second one #10610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 30, 2025

Conversation

jglick
Copy link
Member

@jglick jglick commented Apr 29, 2025

As noted in jenkinsci/remoting#802, I saw a build.xml that had two InterruptedBuildActions, each with one cause of interruption. The intention of causes being a list was presumably that there would be one action enumerating all causes, though the current behavior may be harmless if all callers in fact are prepared to query multiple actions.

* You might also want to call {@link Executor#recordCauseOfInterruption} on {@link #getExecutor}.
advertises that recordCauseOfInterruption may be called externally, which https://github.com/jenkinsci/workflow-job-plugin/blob/5e2896f2283418e36387d59fedc5a46f840a7668/src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowRun.java#L405 in fact does.

for (CauseOfInterruption c : causes) {
if (!this.causes.contains(c))
this.causes.add(c);
}
suggests that the list of causes is intended to not contain duplicates.

Testing done

Automated test, though it is not terribly realistic since freestyle builds only call recordCauseOfInterruption once, in

Executor.currentExecutor().recordCauseOfInterruption(Run.this, listener);

Proposed changelog entries

  • N/A

Proposed changelog category

/label internal

Proposed upgrade guidelines

N/A

Before the changes are marked as ready-for-merge:

Maintainer checklist

  • There are at least two (2) approvals for the pull request and no outstanding requests for change.
  • Conversations in the pull request are over, or it is explicit that a reviewer is not blocking the change.
  • Changelog entries in the pull request title and/or Proposed changelog entries are accurate, human-readable, and in the imperative mood.
  • Proper changelog labels are set so that the changelog can be generated automatically.
  • If the change needs additional upgrade steps from users, the upgrade-guide-needed label is set and there is a Proposed upgrade guidelines section in the pull request title (see example).
  • If it would make sense to backport the change to LTS, a Jira issue must exist, be a Bug or Improvement, and be labeled as lts-candidate to be considered (see query).

exec.recordCauseOfInterruption(build, listener);
}));
FreeStyleBuild b = j.buildAndAssertStatus(Result.NOT_BUILT, p);
assertThat(b.getActions(InterruptedBuildAction.class).stream().map(iba -> iba.getCauses().stream().map(CauseOfInterruption::getShortDescription).toList()).toList(), is(List.of(List.of("one", "two", "three", "four"))));
Copy link
Member Author

Choose a reason for hiding this comment

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

Without fix, fails with

java.lang.AssertionError: 

Expected: is <[[one, two, three, four]]>
     but: was <[[one, two], [three, four]]>
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6)
	at hudson.model.ExecutorTest.recordCauseOfInterruption(ExecutorTest.java:245)

Copy link

@A1exKH A1exKH left a comment

Choose a reason for hiding this comment

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

LGTM.

@NotMyFault NotMyFault requested a review from a team May 29, 2025 10:00
@timja
Copy link
Member

timja commented May 29, 2025

/label ready-for-merge


This PR is now ready for merge, after ~24 hours, we will merge it if there's no negative feedback.

Thanks!

@comment-ops-bot comment-ops-bot bot added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label May 29, 2025
@krisstern krisstern merged commit 622dab2 into jenkinsci:master May 30, 2025
18 checks passed
@jglick jglick deleted the InterruptedBuildAction branch May 30, 2025 15:32
@MarkEWaite MarkEWaite added the skip-changelog Should not be shown in the changelog label May 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback skip-changelog Should not be shown in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants