With Azure Pipeline object API it is possible to get builds.
BuildHttpClient.GetBuildsAsync(params)
Now I can get the changes for a build, because I need to filter the builds by a specific change id (commit hash)
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!
Is there a way to get builds over the API which has a specific change id in one query?
You could get sourceVersion
and id
from BuildHttpClient.GetBuildsAsync
, and filter sourceVersion
directly. sourceVersion
is the changesetId/CommitId. For example:
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);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.