'How to update 'Default agent pool for YAML' for a pipeline in Azure Devops using Rest API?
I have tried to use the definition update api to try to update the 'Default agent pool for YAML' but no success. I kept receiving '200' response status code but the setting stay the same.
I have also tried to capture the actual request content when perform the update manually via UI, then pretty much copied the same content into the Body of the request but the result stayed the same.
Below is a sample of the request that I'm using:
Invoke-WebRequest -URI "https://dev.azure.com/***/***/_apis/build/definitions/***?api-version=6.1-preview.7" -Method PUT -ContentType "application/json" -Headers @{ Authorization = "Basic ***" } -Body '{***}'
The body is in the JSON format of:
{
...
"queue": {
"id": 882,
"name": "Azure Pipelines",
"pool": {
"id": 17,
"name": "Azure Pipelines",
"isHosted": true
}
},
...
}
Update As suggested by the Microsoft team, the feature is not supported. I have logged a suggestion for the feature here.
Solution 1:[1]
This looks to be enabled now, but through a different set of properties. You can set the default pool through the following property:
process.phases.target.agentSpecification.identifier
The relevant snippet looks like this:
"process": {
"phases": [
{
"name": "NameGoesHere",
"target": {
"agentSpecification": {
"identifier": "windows-latest"
}
}
}
]
}
As fair warning: I found that if I had the wrong revision number in my payload, the API will respond with a 200, but the pool won't change. This was especially noteworthy when I was trying to reset the pool through the UI to prove that the API call worked. Essentially, it's probably a good idea to do a GET, modify that payload, and send that to the PUT without any other actions in between.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jeremy Caney |
