In Azure Devops, how to identify a self hosted agent from existing agents. I would like my custom build task to be allowed to execute in self hosted agent only.
Asked
Active
Viewed 516 times
1 Answers
3
You can take advantage of the custom capabilities defined for agents and demands specified in the build pipeline. As noted here:
The agent software automatically determines various system capabilities such as the name of the machine, type of operating system, and versions of certain software installed on the machine. Also, environment variables defined in the machine automatically appear in the list of system capabilities.
Thus, your self-hosted agents can define some special environment variable, which will then be demanded by the build process.

Bernard Vander Beken
- 4,848
- 5
- 54
- 76

Yan Sklyarenko
- 31,557
- 24
- 104
- 139
-
1Implied here but not stated is that the task has to run in it's own agent phase to be able to leverage the demands. If that is the case, it might be easier to just specify the self-hosted queue for that agent phase. ADO will also allow definition of custom capabilities on the agent's Capabilities tab, which is also probably easier than managing the environment variables on the server. – Matt Jan 11 '19 at 18:06