Skip to content

Fix duplicate artifact error on PR pipeline job re-runs - #4508

Open
cheenamalhotra wants to merge 2 commits into
mainfrom
dev/cheena/animated-potato
Open

Fix duplicate artifact error on PR pipeline job re-runs#4508
cheenamalhotra wants to merge 2 commits into
mainfrom
dev/cheena/animated-potato

Conversation

@cheenamalhotra

Copy link
Copy Markdown
Member

Description

Re-running a failed job in the sqlclient-pr pipeline fails with:

##[error]Artifact build_and_pack_projects already exists for build 165347.

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 a displayName to 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.JobId is 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:

  • Nothing downloads build_and_pack_projects by name; it is published for diagnostics only, so the rename has no consumers to update.
  • The coverage collection job downloads artifacts by itemPattern: '**/*.coverage' with no artifact-name filter, so it keeps working with the new names.
  • Trade-off: if a test job is re-run, coverage files from both attempts will now be present and merged, where previously the re-run simply failed at publish time. Failing the whole re-run to avoid slightly skewed coverage is the worse outcome, so this is intentional.

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:

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
Copilot AI review requested due to automatic review settings August 6, 2026 19:53
@cheenamalhotra
cheenamalhotra requested a review from a team as a code owner August 6, 2026 19:53
@github-project-automation github-project-automation Bot moved this to To triage in SqlClient Board Aug 6, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread eng/pipelines/pr/steps/publish-test-results-step.yml Outdated
Comment thread eng/pipelines/pr/stages/pack-stage.yml Outdated
Comment thread eng/pipelines/pr/stages/collect-coverage-stage.yml Outdated
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
Copilot AI review requested due to automatic review settings August 6, 2026 20:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@cheenamalhotra cheenamalhotra added this to the 7.1.0-preview3 milestone Aug 6, 2026
@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.92%. Comparing base (deabcc2) to head (15a8b57).
⚠️ Report is 1 commits behind head on main.

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     
Flag Coverage Δ
CI-SqlClient ?
PR-SqlClient-Project 63.92% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cheenamalhotra cheenamalhotra moved this from To triage to In review in SqlClient Board Aug 7, 2026
@cheenamalhotra
cheenamalhotra enabled auto-merge (squash) August 7, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

4 participants