2
votes

I am working on Azure DevOps YAML pipeline, I am not sure whether we can use single agents through out the pipeline. I have multiple jobs/stages - Build, Deploy, Post-Deploy, and want to assing that to a single agent, because it is consuming same artifacts. Is there a way to assign a single agents through the pipeline.

Thanks in advance.

3
Are you talking about specifically using the same agent for each individual stage, same pool, or same agent throughout all the jobs in a given stage?DreadedFrost
Yes I am talking about using same agent for multiple stages/jobsAbhishek Anvekar
@Abhishek Anvekar Not get your latest information, is the workaround helpful for you? Or if you have any concern, feel free to share it here.Hugh Lin

3 Answers

2
votes

Yes, you can define a specific agent on YAML.

E.g: pool: name: AgentPoolName demands: - agent.name -equals AgentName

https://docs.microsoft.com/en-us/azure/devops/pipelines/process/demands?view=azure-devops&tabs=yaml

1
votes

I dont want the agent to do checkout operation everytime for new job

Using the checkout keyword to configure or suppress this behavior.

steps:
- checkout: none

You can refer to this official document for details.

1
votes

If you cannot use a specif agent as @Savio Moreira suggested the only option that I found is to duplicate some steps.

In my case have a similar pipeline with 2 stage:

  • Build (To validate PR)
    • Visual Studio build
    • Visual Studio Test
    • VS test
  • Publish (To publish the Artifact after merge into master)
    • Visual Studio build
    • Copy file
    • Publish build artifacts

The Build part is trigger only when a PR is created using a condition in the YAML Stage and Enable Branch policies. The Publish part is trigger only when there is merge into master.

It's a bit annoying that some steps need to be duplicated but the execution is unique, and with the same pipeline I can execute validation before merge and then create the artifact once the code is into master.

The checkout option doesn't help since in my case each stage is executed on a completely different container.