Define Code Pipeline Webhook
Last we need to define the Code Pipeline webhook in CES to be able to trigger the build pipeline based on a promote in an Code Pipeline application. The principles and triggering conditions are the same as for the Jenkins examples. The URL for the http request, the headers to use and the body will be different, though.
URL for the http request
The URL will be https://dev.azure.com/{organization}/{project}/_apis/build/builds?api-version=5.1 with organization being the name of your Azure DevOps organization and the project the name of the project containing the build pipeline.
Headers
You will need headers for
- content-type set to application/json
- authorization set to Basic followed by the encryption of your Personal Access Token.
Body
The body will have to look like the following:
"definition": {
"id": 2
},
"project": {
"id": "00c89c7a-d744-4376-a334-6ded05cc242c"
},
"parameters":"{\"ispwApplication\":\"$$application$$\",\"ispwContainerName\":\"$$assignment$$\",\"ispwContainerType\":\"0\",\"ispwLevel\":\"$$level$$\"}"
}
with
- "definition" pointing to the definition ID of the build pipeline you want to trigger
- "project" pointing to the ID of the project containing your pipeline
- "parameters" using a JSON string which lists the pairs of pipeline variables and values to use during the execution of the pipeline
This latter is how to pass values to the parameter of the pipeline via REST calls. The $$value$$ values are passed by the Code Pipeline webhook.