Reputation: 61
I'm trying to write a jenkins job to automatically check status of Azure DevOps tasks to clean git branches connected to the number of task (git is outside of Azure DevOps).
To get the work item, I found an api call:
GET https://dev.azure.com/{organization}/{project}/_apis/wit/queries/{query}?api-version=5.1
However, when i use it (filled with proper information) i get 203 status code:
16:52:19 Response Code: HTTP/1.1 203 Non-Authoritative Information
16:52:19 Success code from [100‥399]
[Pipeline] echo
16:52:19 Status: 203
I found info that i need to use Personal Access Token somehow to get past this, so i created one, but i can't find the example of PAT usage in an api call to Azure DevOps. Anyone figured that out?
Upvotes: 0
Views: 964
Reputation: 61
Thanks Aleksander, the first link pointed me to answer.
curl -u {username}[:{personalaccesstoken}] https://dev.azure.com/{organization}/_apis/projects?api-version=2.0
After that i did some digging about how to do that with HTTP Request Plugin in jenkins:
def response = httpRequest authentication:'credentialsID', url:'https://dev.azure.com/{organization}/{project}/_apis/wit/queries/{query}?api-version=5.1'
where credentialsID is jenkins credentials which contains PAT. And this is the answer to my question. Thanks. Now i need to find a way to extract workitem state from the response. ;)
Upvotes: 0
Reputation: 16163
That`s depends on a framework you use:
Upvotes: 1