-
Gets PAT - personal access token - from azure devops profile. See more on this page.
You can use username:password from 'Alternate credentials', which is also in your profile. -
Use curl with -s - silent, doesn't print statistics. Use
jq
tool for pritty print json content.
> curl -s -u username:PAT -H "Content-Type: application/json" https://dev.azure.com/<organization>/_apis/projects?api-version=2.0 | jq
You can use authorization header directly from the bash tasks from some build/release pipeline with System.AccessToken pipeline variable
> curl -H "Authorization: Bearer $(System.AccessToken)" -H "Content-Type: application/json" \
https://dev.azure.com/<organization>/_apis/projects?api-version=2.0 | jq
Some useful queries:
Get build tags for particular builds
> curl -s -u username:PAT \
-H "Content-Type: application/json" \
https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/tags?api-version=5.1 | jq
What do I have to put in the $(System.AccessToken) variable?
works fine, but I do not manage to invoke azure devops api with bearer token.