Queue build Azure DevOps with Postman

This blog describes how you can use Azure DevOps REST API to queue build from postman, You can find the details around the DevOps REST API here, but it was bit difficult to get information around how you can send the parameters to your build definition.

Microsoft document says you need to specify the parameters as ‘String’ but the structure of the string is not very clear.

In this blog, I will show you how you can send the parameter to your DevOps build.

I have a YAML pipeline that echo’s the variable values.

Pipeline has variable name ‘one’ which has default value as ‘Rakesh’, now if I queue the build and run this, it should log the variable value ‘Rakesh’ using echo command.

you can refer below screen shot the default value of the variable is printed here.

Now lets call queue this build using the REST API via postman.

you can find more details around different parameters here:

Use PAT token to authenticate your rest API using basic authentication

Here he request body:

"definition": {
"id": 20

You can see http method invoked successfully and we have received http status code 200, that means our build is queued.

Now lets try to pass on the variable to our build, let change the request body to do the same.

"definition": {
"id": 20
"parameters": "{\"one\": \"I am from postman\", \"system.debug\":\"true\"}"

Lets check the outcome

you can see the build trigged in Debug mode and also the parameter has changed, now it has printed “I am from postman”.

you can also call the api using curl command

curl --location --request POST '' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic ' \
--data-raw '{
"definition": {
"id": 217
"sourceBranch": "refs/heads/master",
"sourceVersion": "",
"reason": 1,
"demands": [],
"parameters": "{\"system.debug\":\"true\"}"

you can find more details around this on postman site

I have my Youtube channel where I post videos on Azure/Azure DevOps/ Terraform / DotNet technologies every week.
Please Subscribe to my Youtube channel

Rakesh Suryawanshi — Azure Solutions Architect, DevOps with Terraform