Can I have an Azure DevOps Pipeline set a variable based on a group of available options?

273 Views Asked by At

Essentially, I have, say, 10 Pipelines that all run at the same time on 3 available Agents. So only 3 run at a time, and the rest are queued. I need each pipeline to have a variable that I can use for the entire pipeline, but I need that variable to be chosen from a specific list. Furthermore, I would like the variable that is chosen, to not be able to be chosen by another pipeline while it is being used by one. Once that Pipeline is finished, that variable can then be used again by a different Pipeline. So I would like each Pipeline to choose from a list of available options and set one of those options as a Pipeline variable, then free up that option for a later running Pipeline to be able to choose it again. Is this possible?

1

There are 1 best solutions below

4
On

No, this cannot be accomplished. With YAML pipelines you can specify parameters and possible values, but your desired locking requirements can't be added.

Simple, but unfortunate answer.

If what you're trying to do is make sure pipelines aren't accessing the same environments or resources, then you may want to look into the 'Environments' and deployment stages. With policies on the environment or specific environment resources, you can prevent 2 pipelines from attempting to access the same environment or the same resource in an environment at the same time.

There is no queue-time block, the pipeline will just wait its turn.