Skip to content
This repository has been archived by the owner on Jun 9, 2021. It is now read-only.

Commit

Permalink
Update Azure Pipelines Sample to set branch of pull request (#327)
Browse files Browse the repository at this point in the history
* Trigger builds on branches

* triggerInfo is returned by later api calls, properties are not
  • Loading branch information
daveneeley authored and tomasbjerre committed Mar 30, 2019
1 parent f6836b0 commit ab5e796
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion README_azurepiplines.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,22 @@ Here is how to integrate with Azure Pipelines (VSTS).
"definition": {
"id": <build definitionId from url>
}
"reason": "pullRequest",
"sourceBranch": "${PULL_REQUEST_FROM_ID}",
"sourceVersion": "${PULL_REQUEST_FROM_HASH}",
"triggerInfo": {
"url": "${PULL_REQUEST_URL}",
"user": "${PULL_REQUEST_USER_EMAIL_ADDRESS}",
"title": "${PULL_REQUEST_TITLE}",
"version": "${PULL_REQUEST_VERSION}",
"author": "${PULL_REQUEST_AUTHOR_EMAIL}",
"reviewers": "${PULL_REQUEST_REVIEWERS_EMAIL}"
}
}
```
* Encode post content as JSON
* In **Headers** add "Content-Type" with value "application/json"

Additional data can be sent in the post. See [Azure API Docs](https://docs.microsoft.com/en-us/rest/api/azure/devops/build/Builds/Queue?view=azure-devops-rest-5.0) for more info. The build history will state 'Manual build for <owner of personal access token>' for each build triggered by this method.
Additional data can be sent in the post. See [Azure API Docs](https://docs.microsoft.com/en-us/rest/api/azure/devops/build/Builds/Queue?view=azure-devops-rest-5.0) for more info. The triggerInfo collection is not shown in the VSTS UI, but is returned in API calls.

It's a good idea to use a personal access token from a service principal for authentication. The queued builds will all state that they were triggered by the owner of the token.

0 comments on commit ab5e796

Please sign in to comment.