admin管理员组文章数量:1431434
I am trying to enhance my (C#) utility that can currently already Create a pull request using the GitHttpClient. I can query the PR and update it using UpdatePullRequestAsync.
What i am currently struggling with is to find a way to get the state of the build(s) that are linked to the PR. I explored the dotnet samples, but these are fairly limited: .cs
The statuses are empty. What would be the correct/best way to get the build status for a pull request using the client libraries?
In the end, i want to (force) complete my pull request if all the linked builds are successful. Which if im correct should be done like this:
// now complete the PR
var updatedPr = new GitPullRequest()
{
Status = PullRequestStatus.Completed,
CompletionOptions = new GitPullRequestCompletionOptions() { SquashMerge = true, DeleteSourceBranch = true, BypassPolicy = true }
};
var prStatus = gitClient.UpdatePullRequestAsync(updatedPr, repoId, pullRequestId).Result;
How can help me point to the right way getting this information?
I am trying to enhance my (C#) utility that can currently already Create a pull request using the GitHttpClient. I can query the PR and update it using UpdatePullRequestAsync.
What i am currently struggling with is to find a way to get the state of the build(s) that are linked to the PR. I explored the dotnet samples, but these are fairly limited: https://github/microsoft/azure-devops-dotnet-samples/blob/main/ClientLibrary/Samples/Git/PullRequestIterationStatusesSample.cs
The statuses are empty. What would be the correct/best way to get the build status for a pull request using the client libraries?
In the end, i want to (force) complete my pull request if all the linked builds are successful. Which if im correct should be done like this:
// now complete the PR
var updatedPr = new GitPullRequest()
{
Status = PullRequestStatus.Completed,
CompletionOptions = new GitPullRequestCompletionOptions() { SquashMerge = true, DeleteSourceBranch = true, BypassPolicy = true }
};
var prStatus = gitClient.UpdatePullRequestAsync(updatedPr, repoId, pullRequestId).Result;
How can help me point to the right way getting this information?
Share Improve this question edited Nov 19, 2024 at 12:03 jonrsharpe 122k30 gold badges268 silver badges476 bronze badges asked Nov 19, 2024 at 12:02 NicoNico 7197 silver badges28 bronze badges 1 |1 Answer
Reset to default 0As far as I have tested, you may try and use GetPullRequestStatusesAsync
to get the PR iteration statuses.
Here is my code snippet for your reference.
// Get the pull request statuses
var statuses = gitClient.GetPullRequestStatusesAsync(projectName, repoName, pullRequestId).Result;
// Serialize the object to JSON
string statusesJson = JsonConvert.SerializeObject(statuses, Formatting.Indented);
// Print the JSON
Console.WriteLine("============ Satuses ============");
Console.WriteLine(statusesJson);
本文标签: Get state of build policies in Azure DevOps Pull requestStack Overflow
版权声明:本文标题:Get state of build policies in Azure DevOps Pull request - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745563288a2663603.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
GetPullRequestStatusesAsync
to get the statuses of the validation build iterations? Hope your query in this post can be resolved. Thx. – Alvin Zhao Commented Nov 25, 2024 at 7:02