[英]Azure DevOps: Can we identify Builds triggered from a changeset number?
I have certain builds set for Continuous Integration, ie, build for every check-in.我为持续集成设置了某些构建,即为每次签入构建。 I have an automated method to perform code merge and check-ins;我有一个自动化的方法来执行代码合并和签入; now I want to get the list of builds triggered for a particular changeset created.现在我想获取为创建的特定变更集触发的构建列表。 Is there any way we could get this information?我们有什么办法可以得到这些信息?
I would use the the REST API so you could check for builds that were run:我将使用 REST API 以便您可以检查运行的构建:
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds
will return all builds that you could then go through and check for more details.将返回您可以通过 go 的所有构建并检查更多详细信息。 You can also have more filters in the request (for example based on the build definition).您还可以在请求中包含更多过滤器(例如基于构建定义)。
The build specifics you could then get via:然后您可以通过以下方式获得构建细节:
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/<buildid>
This will return you the infos like:这将返回您的信息,如:
"triggerInfo": {
"ci.sourceBranch": "refs/heads/master",
"ci.sourceSha": "0fcb5a27ca2f73561dde0a066a1ec1781128fa81",
"ci.message": ""
},
...
"sourceBranch": "refs/heads/master",
"sourceVersion": "0fcb5a27ca2f73561dde0a066a1ec1781128fa81",
for builds queued from a git repository or对于从 git 存储库排队的构建或
{ ...
"sourceBranch": "$/Build Test",
"sourceVersion": "93",
... }
for TFVC repositories.用于 TFVC 存储库。 It actually also would contain a trigger info but I don't have any build around that was triggered automatically based on TFVC.它实际上也将包含触发信息,但我没有任何基于 TFVC 自动触发的构建。
The sourceVersion
in git will be the commit hash, where in TFVC it's the changeset. sourceVersion
中的 sourceVersion 将是提交 hash,其中在 TFVC 中它是变更集。
More details on the REST API can be found in the Microsoft Docs有关 REST API 的更多详细信息,请参阅Microsoft Docs
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.