Fix duplicate artifact error on PR pipeline job re-runs - #4508
Open
cheenamalhotra wants to merge 2 commits into
Open
Fix duplicate artifact error on PR pipeline job re-runs#4508cheenamalhotra wants to merge 2 commits into
cheenamalhotra wants to merge 2 commits into
Conversation
Pipeline artifact names must be unique within a build, so re-running a failed job in the sqlclient-pr pipeline failed with "Artifact build_and_pack_projects already exists for build <id>." Suffix the published artifact names with $(System.JobAttempt) in the pack, coverage, and test-results publish steps. System.JobId is stable across attempts of the same job, so the test-results artifact had the same latent collision. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8612610a-cd1b-4668-b818-ce555b5ffd14
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates Azure Pipelines artifact naming to avoid collisions when re-running failed jobs by including the job attempt number in published artifact names.
Changes:
- Append
$(System.JobAttempt)to pipeline artifact names for test results, build output, and merged coverage. - Add inline documentation explaining why attempt-based uniqueness is required.
- Add a display name to the build output publish step.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| eng/pipelines/pr/steps/publish-test-results-step.yml | Makes test-results artifact names unique per job attempt and documents the rationale. |
| eng/pipelines/pr/stages/pack-stage.yml | Makes build output artifact names unique per job attempt and improves step labeling/docs. |
| eng/pipelines/pr/stages/collect-coverage-stage.yml | Makes merged coverage artifact names unique per job attempt and documents the rationale. |
Address review feedback by moving the artifact base names into pr-variables.yml and passing them into the pack and coverage stage templates, matching the existing testResultsArtifactBaseName pattern. This keeps producers and any future consumers in sync via a single definition. Also correct a doc comment to reference parameters.testResultsArtifactBaseName. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8612610a-cd1b-4668-b818-ce555b5ffd14
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4508 +/- ##
==========================================
- Coverage 64.71% 63.92% -0.79%
==========================================
Files 288 283 -5
Lines 44088 67041 +22953
==========================================
+ Hits 28532 42858 +14326
- Misses 15556 24183 +8627
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
paulmedynski
approved these changes
Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Re-running a failed job in the
sqlclient-prpipeline fails with:Azure Pipelines requires artifact names to be unique within a build. The pack job publishes its build output under a fixed name, so attempt 2 of that job tries to publish an artifact that attempt 1 already created and the re-run fails before it can do anything useful.
This change suffixes the published artifact names with
$(System.JobAttempt)in the PR pipeline:eng/pipelines/pr/stages/pack-stage.yml-build_and_pack_projects_attempt$(System.JobAttempt). This is the reported failure. Also added adisplayNameto the publish step so it is easier to spot in the log.eng/pipelines/pr/steps/publish-test-results-step.yml- appended the attempt number.System.JobIdis stable across attempts of the same job, so the test-results artifact carried the same latent collision and would fail on any test job re-run.eng/pipelines/pr/stages/collect-coverage-stage.yml-merged_coverage_attempt$(System.JobAttempt), for the same reason.Notes for reviewers:
build_and_pack_projectsby name; it is published for diagnostics only, so the rename has no consumers to update.itemPattern: '**/*.coverage'with no artifact-name filter, so it keeps working with the new names.Issues
N/A - reported directly from a pipeline failure on build 165347.
Testing
No automated tests. These are Azure Pipelines YAML changes with no product code impact; the repo has no YAML pipeline test harness. Validated that all three files still parse as YAML and confirmed by inspection that no template or task references the renamed artifacts. Final verification is the pipeline itself: the pack, test, and coverage jobs should publish normally, and re-running a failed job should now succeed instead of erroring on a duplicate artifact name.
Guidelines
Please review the contribution guidelines before submitting a pull request: