0
votes

I have a CI build set up in Devops that runs with every Pull Request submitted for our master branch, and then also on a daily schedule whenever our master branch has been updated (after successful review).

When I look at the pipeline history, the builds that ran for PR's have no linked Work Items (even though items were linked in the Pull Request).

Only the builds that run AFTER the PR has completed and merged into master (ie the ones that run against master, not the PR branch) have the items from the Pull Request linked.

Is it possible to link work items from the PR to the PR build or at least access them from the CI pipeline?

I'd like to add a task to my CI pipeline that automatically updates all Work Items linked to a PR to "In Code Review" status when the CI build for the Pull Request starts, but the items are only available in the post-PR builds.

1
It is possible to access PR data but with a bit workaround, like here: stackoverflow.com/questions/60041668/…Mario Dietner

1 Answers

1
votes

If you want to display the linked work items on the summary page of the build triggered by the pull request, you need to add the linked work items on the Commit page.

![enter image description here

enter image description here

The linked work items added in the pull request page will not be displayed on the build summary page.

enter image description here

Currently, this is by design. If we want to get the work items from the pull request link to the build, we can get them through rest api, but they will not be displayed in the build summary.

GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/workitems?api-version=6.0

enter image description here

Here is a ticket with similar issue you can refer to.