How to run two agents in parallel in Azure DevOps?

Viewed 395

In this release pipeline, I have two tasks: one is running the kubectl command, and I need it to keep running while I run the second task. After researching for a while, I know that parallel tasks are not available in Azure DevOps, so I tried with multiple agents. However I could not make it work.

May I know which part am I missing?

My current config looks like this:

enter image description here

And in each of the agents, I selected "Multi-Agent" on parallelism with number of 2.

But it seems not the one I want.

What I want is, run the first job with kubectl port-forward command. And keep it running while second job start running. After second job Run script is finished, then the first job can end.

May I know in Azure DevOps is there a way to achieve this?

Thank you so much.

1 Answers

The easiest would be actually to use seprate stages. But if you want to use single stage you can do it as follows:

Define variable like this:

enter image description here

Configure parallelism on the job:

enter image description here

And then define custom condition on the tasks:

enter image description here

One task should have eq(variables['Script'], 'one') and the other eq(variables['Script'], 'two')

You will get two agents runs your jobs but in each job will actually do only one task:

enter image description here

enter image description here

Related