Skip to content

Handle attachments from the "same" test from different branches/nodes#203

Merged
jonesbusy merged 6 commits intojenkinsci:mainfrom
jtnord:tests-in-branches
Feb 24, 2026
Merged

Handle attachments from the "same" test from different branches/nodes#203
jonesbusy merged 6 commits intojenkinsci:mainfrom
jtnord:tests-in-branches

Conversation

@jtnord
Copy link
Copy Markdown
Member

@jtnord jtnord commented Feb 23, 2026

When the same test was recorded with the same attachment paths (but on different nodes) then wen viewing test results you would only be able to see one of the attachments.

The testData now records the flow ids so that attachments from different flows can be disambiguated.

Also tested interactively by:

  • without the fix, create a pipeline using the pipeline from the unit tests
  • ran a build and checked the test results and data (only one branch is present)
  • upgraded the plugin to a locally built version with this fix
  • checked the old results where still present (only one attachment was still obtainable)
  • ran a build and checked the test results and data (both attachments are available)

fixes: #202

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

jtnord and others added 4 commits February 23, 2026 15:12
Use SuiteResult.getEnclosingBlocks() to namespace attachment storage
paths and filter Data.getTestAction() by matching enclosing flow node
IDs, so that parallel pipeline branches with the same test don't
overwrite each other's attachments or produce duplicate actions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jtnord jtnord changed the title Unit test demonstrating issue with attachments from the same test Handle attachments from the "same" test from different branches/nodes Feb 24, 2026
@jtnord jtnord marked this pull request as ready for review February 24, 2026 13:31
@jtnord jtnord requested a review from a team as a code owner February 24, 2026 13:31
@jonesbusy jonesbusy added the bug label Feb 24, 2026
@jonesbusy jonesbusy self-assigned this Feb 24, 2026
@jonesbusy jonesbusy requested review from Copilot February 24, 2026 13:41
…ableList)

@jglick warns against using imutable lists in serialisation.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes attachment collisions when the same test (same attachment paths) is executed multiple times in different Pipeline branches/nodes by namespacing attachment storage/actions using the test suites’ enclosing flow blocks.

Changes:

  • Namespace attachment storage per flow (enclosing blocks) and pass that context through AttachmentPublisher.Data.
  • Filter/partition TestAction rendering by enclosing blocks and disambiguate class-level action URL names.
  • Add Pipeline regression tests covering parallel-branch executions and class-result attachment rendering.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/main/java/hudson/plugins/junitattachments/AttachmentPublisher.java Propagates/enforces enclosing-block scoping for actions and attachment root resolution.
src/main/java/hudson/plugins/junitattachments/GetTestDataMethodObject.java Derives enclosing blocks from suites and namespaces attachment storage path accordingly.
src/main/java/hudson/plugins/junitattachments/TestClassAttachmentTestAction.java Disambiguates class attachment action URL name and updates URL generation to use it.
src/test/java/hudson/plugins/junitattachments/AttachmentPublisherPipelineTest.java Adds regression tests for parallel branches and updates URL/content fetching helper logic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@jonesbusy
Copy link
Copy Markdown
Contributor

Thanks!

@jonesbusy jonesbusy merged commit 3075775 into jenkinsci:main Feb 24, 2026
16 checks passed
@jtnord jtnord deleted the tests-in-branches branch February 24, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Attachments not correct when a test is run multiple times in different branches)

3 participants