簡體   English   中英

Azure DevOps 服務器 object Api 通過更改 id 獲取構建

[英]Azure DevOps Server object Api get builds by change id

使用 Azure 管道 object API 可以獲得構建。

BuildHttpClient.GetBuildsAsync(params)

現在我可以獲取構建的更改,因為我需要通過特定的更改 id(提交哈希)過濾構建

BuildHttpClient.GetBuildChangesAsync(params, buildId)
// Here I can loop over the changes and search for a specific change id (commit hash)
// But this scales very bad, getting the changes is really slow. Doing this on tousand of builds can take minutes!

有沒有辦法在 API 上構建,它在一個查詢中具有特定的更改 ID?

您可以從BuildHttpClient.GetBuildsAsync獲取sourceVersionid ,並直接過濾sourceVersion sourceVersion是 changesetId/CommitId。 例如:

        string _personalAccessToken = "xxxxxxxxx";
        VssBasicCredential credentials = new VssBasicCredential("", _personalAccessToken);
        var connection = new VssConnection(new Uri(@"https://dev.azure.com/xxxx"), credentials);
        var buildServer = connection.GetClient<BuildHttpClient>();
        var builds = buildServer.GetBuildsAsync($"teamprojectname").Result;

        foreach (var build in builds)
        {
            if (build.SourceVersion == "commitID")
            {
                Console.WriteLine(build.Id);
            }
        }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM