Forum Discussion

ThisBytes5's avatar
ThisBytes5
Copper Contributor
Apr 20, 2022

Build Rest API ignores demands

Builds - Queue - REST API (Azure DevOps Build) | Microsoft Docs

 

If I'm reading the above documentation correctly I should be able to pass a list of demands when I'm Queuing a build.

 

I'm calling the following url:

return $"https://dev.azure.com/{org}/{ProjectConfiguration.ProjectName}/_apis/build/builds?api-version=6.0"; }

 

with following data:

{"definition":{"id":"539"},"sourceBranch":"Dev","demands":[{"name":"Massrun","value":"True"}]}

 

Not sure what I'm doing wrong, also tried it without specifying Name, value as such (typed by hand so may not be 100%)

{"definition":{"id":"539"},"sourceBranch":"Dev","demands":["Massrun":"True"}]}

 

Any help would be greatly appreciated, google/Bing hasn't turned up anything useful so far.

  • Larsen_B's avatar
    Larsen_B
    Copper Contributor

    ThisBytes5 

    I ran into this exact issue when trying to use the Agent.Name demand in the API call to force a specific agent to run a pipeline. The syntax that actually worked was quite different from the documented one:

     

    For my Agent.Name demand this syntax worked:
    {"definition":{"id":"1234"},"demands":[{"value":"Agent.Name -equals agent-01"}]}

     

    For your example this should do the trick
    {"definition":{"id":"539"},"sourceBranch":"dev","demands":[{"value":"Massrun -equals True"}]}

     

    This worked in on-prem Azure Devops Server 2020

Resources