I am looking for a way to set in Azure DevOps .yaml file dynamic demand name.
Right now we have a few self-hosted build agents that are selected by Azure DevOps services randomly but sometimes we need to choose one agent to investigate why it is not working(or for other rare event). One way is to switch off all other agents and operate on this one desired(it affects our whole CI/CD). Second way is adding temporary pipeline and moving desired agent to next agent pool(it costs time).
I think best solution would be possibility to dynamically set demands. For example I can have in variable groups these:
"DemandName" = "IsBuildAgent"
"DemandValue" = "Yes"
Each agent would have this environment variable set ant it would always allow each agent to run pipeline, but if I would set before running pipeline below variables.
"DemandName" = "AgentNumber"
"DemandValue" = "BuildAgentNr6"
It would override library variables and only one agent would be able to run this pipeline.
pool:
name: MyBuildAgents
demands: $(DemandName) -equals $(DemandValue)
DemandValue is correctly evaluated but DemandName cannot be set right now. Is it possible to achieve in slightly changed way? Maybe should I change syntax? Or maybe should I propose this as new feature?
Is it possible to achieve in slightly changed way? Maybe should I change syntax? Or maybe should I propose this as new feature?
Your syntax is correct.
I am afraid there is no such out of box or slightly changed way to achieve it.
Just like you test, DemandName
cannot be set right. That because the left side of the equation is treated as a string instead of a value according to the grammatical rules. This will cause Azure devops to find the demand name
as a string $(DemandName)
instead of the value of $(DemandName)
and then looking for the demand name based on the value.
Hope this helps.