Nmaster88
Nmaster88

Reputation: 1585

How can i know that a pipeline is using a microsoft hosted agent when running a pipeline?

In the project i'm working on, when i run some of the pipelines, they are configure to use by default an old agent pool that supposedly doesn't exist anymore.

If i go to Project settings > Agent pools i don't see it there anymore.

My question is if when i run the pipeline

enter image description here

If there is any place i can use to tell if the pipeline is using a self-hosted or microsoft-hosted agent?

Upvotes: 1

Views: 1149

Answers (4)

Patryk
Patryk

Reputation: 339

As previous answers highlighted - you can use Agent.Name variable name.

In addition, if you want to perform some custom action for your Microsoft-hosted agent only you can do it like in the example below:

    - script: |
        echo "Agent.Name = $(Agent.Name)"
        pip install poetry
      displayName: Run only on Azure hosted VM
      condition: eq(variables['Agent.Name'], 'Hosted Agent')

Upvotes: 0

Nmaster88
Nmaster88

Reputation: 1585

The answer of @VinceBowdren gives an hint how we can get information about the agent of the running pipeline.

But specifically about the agent pools asked in the question, "Hosted" and "Hosted VS2017", they are deprecated microsoft hosted agents. Thats the reason they dont appear anymore in the agent pools list.

Pipelines that are configured using this agent pools will still be able to use them, but as soon as we save the pipeline to use another agent pool, it will not be possible to use them ever again.

We can confirm that these agent pools were deprecated here https://learn.microsoft.com/en-us/azure/devops/release-notes/2019/sprint-155-update#single-hosted-pool

Upvotes: 0

JTIM
JTIM

Reputation: 2771

You can use the variable Agent.Name If you want to write out or do something specific according to the agent.

Upvotes: 0

Vince Bowdren
Vince Bowdren

Reputation: 9208

The pipeline logs show you which pool and which agent are being used:

"Initialize job" pipeline log

Starting: Initialize job
Agent name: 'ReleaseServerB-A002'
Agent machine name: 'ReleaseServerB'
Current agent version: '2.195.2'

Upvotes: 2

Related Questions