Sentry中的Azure DevOps集成:关联提交 [英] Azure DevOps integration in Sentry: Associate commits

查看:55
本文介绍了Sentry中的Azure DevOps集成:关联提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人设法将Azure DevOps集成到Sentry(sentry.io)中吗?我停留在将发布与提交相关联"(请参阅​​:

然后,您可以将变量 $(id)应用于该API,并在powershell任务中执行api:

 "refs":[{"commit":"$(id)"}] 

现在,提交ID 可以打包到此api的主体中,并发送到Sentry服务器.


如果有多个与该版本相关的提交,因为上面提到的变量 $(Release.Artifacts.{alias} .SourceVersion)消息,您可能需要在此处添加其他脚本,以通过 Build id 获得所需的内容.

在发布管道中,使用$(Build.BuildId)您可以获得与该版本关联的相应 buildid .然后,您可以使用此

您可以将这些powershell脚本应用到您的任务中,而无需进行任何更改,因为该脚本在VSTS中的powershell-ise,powershell命令行和powershell任务中是通用的.

  $ token ="{PAT令牌}"$ url ="https://dev.azure.com/{组织名称}/{项目名称}/_ apis/build/changes?fromBuildId = {id1}& toBuildId = {id2}"$ token = [System.Convert] :: ToBase64String([System.Text.Encoding] :: ASCII.GetBytes(:$($ token)"))$ response = Invoke-RestMethod -Uri $ url -Headers @ {Authorization ="Basic $ token"} -Method Get写主机结果= $($ response.value.id | ConvertTo-Json-深度100)" 

现在,您可以获得与构建和相应发行版关联的提交列表.

Did someone manage to integrate Azure DevOps in Sentry (sentry.io)? I stuck on "Associate commits with a Release" (see: https://docs.sentry.io/workflow/releases/?platform=browser#associate-commits-with-a-release)

I can not figure out a way how I can tell Sentry (by API) which commit ids are associated with a current release/deploy. How can I add a task to the pipeline which will post the commit ids to Sentry API? Or is there some other way to do it?

解决方案

In azure devops, the Powershell task also support curl. So, you can execute the api in powershell task of VSTS pipeline directly.

In release pipeline, there has a pre-defined release variable, it stores the commit id which is associated with the current release pipeline: $(Release.Artifacts.{alias}.SourceVersion). Here alias is the artifacts name, and you can get it by getting $(Release.PrimaryArtifactSourceAlias).

First, create variables like this:

Then you can apply the variable $(id) into that API, and execute the api in powershell task:

"refs": [{
 "commit":"$(id)"
 }]

Now, the commit id could be packed into the body of this api, and send to the Sentry server.


If there has multiple commits associate with this release, since the variable $(Release.Artifacts.{alias}.SourceVersion) I mentioned above only store the latest commit message, here you may need add additional scripts to get what you want by Build id.

In release pipeline, with $(Build.BuildId) you can get the corresponding buildid which associate with this release. And then, you could get the commits(changes) by using this API:

GET https://dev.azure.com/{organization}/{project}/_apis/build/changes?fromBuildId={fromBuildId}&toBuildId={toBuildId}&api-version=5.1-preview.2

You could apply these powershell script into your task without change anything because this script is universal among powershell-ise, powershell command line and powershell task in VSTS.

$token = "{PAT token}"
$url="https://dev.azure.com/{org name}/{project name}/_apis/build/changes?fromBuildId={id1}&toBuildId={id2}"
$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.value.id | ConvertTo-Json -Depth 100)"

Now, you could get the list of commits which associate with the build and corresponding release.

这篇关于Sentry中的Azure DevOps集成:关联提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆