Is there a way to get Git Commits that are linked to a work item given only the work item ID?
I'm using PowerShell and this URI to get work items, but I don't see any of the linked commits on the returned object. I also don't see any documentation on how to get these links.
$Results = Invoke-RestMethod -Uri "http://azuredevops/azuredevops/Collection/Project/_apis/wit/workitems?api-version=5.1&ids=1" -Method "GET" -UseDefaultCredentials | Select-Object -ExpandProperty Value
$Results.fields
Click the Repositories and the Branches Menu in the Azure DevOps Portal . Locate in the branch list the one you are going to use to build from, typically that should be your master branch, and click the options icon. Select Branch policies. Check the option ”Check for linked work items”.
You can link work items to existing builds from the Add link dialog. From the Links tab of a work item, choose Add link>Existing item. From the Add link dialog, choose one of the build link types—Build, Found in build, Integrated in build— and specify the build number.
Welcome to the Azure DevOps Services/Azure DevOps Server REST API Reference. Representational State Transfer (REST) APIs are service endpoints that support sets of HTTP operations (methods), which provide create, retrieve, update, or delete access to the service's resources.
You can click on a commit ID or commit message to open the commit details page. Build and PR information - You can view the pull request that brought this commit to the branch selected on the page, and view the build status of the current commit.
You are very close to the correct solution.
The commits which linked to the work item is relation of work item. So, here, you need to specify $expand
in API to get the corresponding commits content.
Get https://dev.azure.com/{org name}/{project name}/_apis/wit/workitems/{id}?$expand=relations&api-version=5.1
Then you would see the commits in relations
part of the response body:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With