The TFS 2017 Update 2 added the feature for manually starting pull request builds.
Manual triggers are useful for things like automated test runs that might take a long time to run, and you only really need to run once before completing the pull request
As seen in Builds REST API Reference I would now want to trigger a validateShelfset Build, as pressing the button
would do. When I compared my JSON Request builds with the "Button pressed" builds via http://MYTFS:8080/tfs/COLLECTION/PROJECT/_apis/build/builds?api-version=3.0 the only notable difference was
reason: "validateShelveset",
and the parameterlist. So I changed my JSON to:
POST http://MYTFS:8080/tfs/COLLECTION/PROJECT/_apis/build/builds?api-version=3.0
Calling POST content:
{
"definition": {
"id": 2
},
"sourceBranch": "refs/pull/26/merge",
"reason": "validateShelveset",
"parameters": "{\"system.pullRequest.pullRequestId\":\"26\",\"system.pullRequest.sourceBranch\":\"refs/heads/feature/myfeaturebranch\",\"system.pullRequest.targetBranch\":\"refs/heads/develop\"}"
}
But while web-UI started builds are seen as Pull Request builds, and have the reason validateShelveset
the POST started builds are seen as private.
I even tried (just to see whether using the reason field would be recognized by TFS) the reason: checkInShelveset, which TFS Recognized correctly as such a build.
Basically all I want to do is to emulate the "Queue build" button in a cmdline interface, and when I look at the Build API it seems as if I am doing the right thing; am I missing something obvious? The documentation does not cover how to add the (quite newly added feature) manual Pull request builds.
Based on my test, you can use the REST API with PATCH method to trigger the Pull Request Validation Build.
eg:
PATCH http://server:8080/tfs/DefaultCollection/feb1793b-4d91-4be4-8373-02216ec5c36b/_apis/policy/Evaluations/0891d5a4-fee9-4751-8bc6-ff403c2860f1?api-version=3.2-preview
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.