I am using Azure pipelines to build and release my software through its GitHub integration. As part of monitoring, I am using Sentry to record exceptions, etc.
I want to use the "Suspect Commits" feature of Sentry (so it can point at commits that are likely to have caused a specific issue). For this to work, I need to send Sentry a release (just a version associated with a specific project) with a list of associated commits relating to it.
I've read this post:
Azure DevOps integration in Sentry: Associate commits
And this one on GitHub:
https://github.com/getsentry/sentry/issues/11127
And while both have (very different) approaches to getting a list of commits, they assume that one is using the Azure DevOps repositories feature. I have no repositories on my DevOps instance, so, though useful posts, they don't really help me directly.
In short - I need to list all the commits on GitHub associated with a specific release on Azure DevOps, so I can send them to the Sentry API.
Has anyone done this? How can I achieve that? Am I missing something obvious?
As I mentioned in comment, the get-changes api which used in this ticket does not suitable for the build pipeline that has github repos source.
But, what fortunate is, we has fully feature support for github cloud. So here you can use another one to get such associate commits list, the one which does not be documented by us.
GET https://dev.azure.com/{org name}/{project name}/_traceability/runview/changes?currentRunId={build id}&__rt=fps&__ver=2
Most of time, you can consider to catch some records from F12
, when you find no way from documents we public. Above api can be got from F12 while you click on the Changes
link in Build Summary
page:
I wrote a complete powershell script, which you can directly make use it in release pipeline to get commits id from its response body:
$token = "{PAT token}"
$url="https://dev.azure.com/{org name}/{project name}/_traceability/runview/changes?currentRunId={build id}&__rt=fps&__ver=2"
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))
$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token"} -Method Get
Write-Host "results = $($response.fps.dataProviders.data.'ms.vss-traceability-web.traceability-run-changes-data-provider'.artifactsData.data.id | ConvertTo-Json -Depth 100)"
In release pipeline, we provide one built-in environment variable that you can directly get the corresponding triggered Build id: $(Build.Buildid)
. And you can inject this into api to make the build id can be get automatically during the CI+CD process.
Update on 3/4/2020:
Based on the screenshot you shared in our discussion, the data structure on yours is for git repo (not sure why, will dig that) :
Please transfer the pipeline with YAML. Then trigger it and write the commits with the scripts I shared above. You will see commits data from the results of YAML.
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