I have a Azure DevOps pipeline where several stages run in parallel. One of those stages takes a lot longer to run than the others. Is there any way to make sure that specific stage is started first?
All of the options I found make other stages wait for this stage to finish. I do not want. The stages do not depend on each other.
The pipeline will just take less time overall if the slowest stage is started first. Is there a way to push it to the top of the queue?
2
Answers
From Specify jobs in your pipeline:
The only workaround I can think of is to add a dummy job to all the stages except the one that takes longer.
Example:
When we run a new build all the jobs without dependencies will be added to the queue randomly – for example:
Sleep job C0
Long job A1
Sleep job B0
Job B1
andJob C1
are not queued immediately because they depend onSleep job B0
andSleep job C0
respectively. They will be added to the queue and run at a later stage, but only afterLong job A1
starts.Final order of the execution of jobs would be something like:
Sleep job C0
Long job A1
Sleep job B0
Job C1
Job B0
As the doc shared by @Rui Jarimba, Azure Pipelines does not support job priority for YAML pipelines.
I would like to share another workaround for the requirement.
You can split the stages into two pipelines. One pipeline is used to run the long time stage and the other pipeline is used to run other stages.
You can trigger the pipeline (run long time stage) first, after the pipeline is running, you can trigger the another pipeline to run other stages.
In this case, we can make sure that the long time stage can start first. And all stages still can run in parallel.
If the stages contains multiple jobs, you can use the Run Next Option to increase the job priority.
For example:
After clicking this option, the current job will be put to the top of the queue.
Refer to this doc: Run this job next