Warm tip: This article is reproduced from stackoverflow.com, please click
azure-pipelines
get build agent information for build
发布于 2020-03-27 10:27:01
Our application is called by the build-successful event web hook of Azure Pipelines. Is there a way to obtain the build agent on which the build was performed? Either directly from the web hook data (doesn't look like it...) or via the API somehow?
The build succeeded webhook always returns a "queue" property which specifies the worker which handled the build. Which job of the build has run on which worker (at least the worker name) is visible if you access the timeline for the build.
Would be nice if someone would know how to find out the ID of the worker instead of just the name (which may exist multiple times)
You can add the powershell task to the agent job of the build pipeline. Because agent.id is an environment variable, you can write the "Write-Host agent id : $(agent.id)" script directly to see the agent id through powershell.
You have to wait for 48 hours until you can accept your own answer ;-)