Sentry 中的 Azure DevOps 集成:关联提交
Azure DevOps integration in Sentry: Associate commits
是否有人设法将 Azure DevOps 集成到 Sentry (sentry.io)?我坚持 "Associate commits with a Release"(参见:https://docs.sentry.io/workflow/releases/?platform=browser#associate-commits-with-a-release)
我不知道如何告诉 Sentry(通过 API)哪些提交 ID 与当前 release/deploy 关联。我如何向管道添加任务,该任务将 post 提交 ID 到哨兵 API?或者有其他方法吗?
在 azure devops 中,Powershell
任务也支持 curl
。因此,您可以直接在 VSTS 管道的 powershell 任务中执行 api。
在发布管道中,有一个pre-defined release variable,它存储与当前发布管道关联的提交ID:$(Release.Artifacts.{alias}.SourceVersion)
。这里alias
是神器名,可以通过获取$(Release.PrimaryArtifactSourceAlias)
.
得到
首先,像这样创建变量:
然后你可以将变量$(id)
应用到那个API,并在powershell任务中执行api:
"refs": [{
"commit":"$(id)"
}]
现在,commit id
可以打包到这个api的主体中,并发送到哨兵服务器。
如果有多个提交与此版本关联,因为我上面提到的变量 $(Release.Artifacts.{alias}.SourceVersion)
仅存储 latest 提交消息,此处您可能需要添加其他脚本通过 Build id.
得到你想要的
在release pipeline中,通过$(Build.BuildId)可以获取对应的buildid,与该release相关联。然后,您可以使用此 API:
获得提交(更改)
GET https://dev.azure.com/{organization}/{project}/_apis/build/changes?fromBuildId={fromBuildId}&toBuildId={toBuildId}&api-version=5.1-preview.2
您可以将这些 powershell 脚本应用到您的任务中而无需进行任何更改,因为此脚本在 VSTS 中的 powershell-ise、powershell 命令行和 powershell 任务中是通用的。
$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)"
现在,您可以获得与构建和相应版本关联的提交列表。
是否有人设法将 Azure DevOps 集成到 Sentry (sentry.io)?我坚持 "Associate commits with a Release"(参见:https://docs.sentry.io/workflow/releases/?platform=browser#associate-commits-with-a-release)
我不知道如何告诉 Sentry(通过 API)哪些提交 ID 与当前 release/deploy 关联。我如何向管道添加任务,该任务将 post 提交 ID 到哨兵 API?或者有其他方法吗?
在 azure devops 中,Powershell
任务也支持 curl
。因此,您可以直接在 VSTS 管道的 powershell 任务中执行 api。
在发布管道中,有一个pre-defined release variable,它存储与当前发布管道关联的提交ID:$(Release.Artifacts.{alias}.SourceVersion)
。这里alias
是神器名,可以通过获取$(Release.PrimaryArtifactSourceAlias)
.
首先,像这样创建变量:
然后你可以将变量$(id)
应用到那个API,并在powershell任务中执行api:
"refs": [{
"commit":"$(id)"
}]
现在,commit id
可以打包到这个api的主体中,并发送到哨兵服务器。
如果有多个提交与此版本关联,因为我上面提到的变量 $(Release.Artifacts.{alias}.SourceVersion)
仅存储 latest 提交消息,此处您可能需要添加其他脚本通过 Build id.
在release pipeline中,通过$(Build.BuildId)可以获取对应的buildid,与该release相关联。然后,您可以使用此 API:
获得提交(更改)GET https://dev.azure.com/{organization}/{project}/_apis/build/changes?fromBuildId={fromBuildId}&toBuildId={toBuildId}&api-version=5.1-preview.2
您可以将这些 powershell 脚本应用到您的任务中而无需进行任何更改,因为此脚本在 VSTS 中的 powershell-ise、powershell 命令行和 powershell 任务中是通用的。
$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)"
现在,您可以获得与构建和相应版本关联的提交列表。