Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect if running in Azure DevOps pipeline?

Tags:

azure-devops

Are there any widely accepted methods for an *.exe to detect if it's running as part of an ADO pipeline? The script will be running both as part of a pipeline and on workstations and should be able to determine with very high confidence where it is running, if possible.

Eg. any pre-defined variables that are meant for this (could not find) or some other pre-defined value that can be inspected?

like image 265
gwow12345 Avatar asked Jan 27 '26 08:01

gwow12345


1 Answers

There is a whole number of predefined variables, most of which you could use, I would say. However, there is one which sounds like what you are looking for:

TF_BUILD

Set to True if the script is being run by a build task.

This variable is agent-scoped, and can be used as an environment variable in a script and as a parameter in a build task, but not as part of the build number or as a version control tag.

like image 192
silent Avatar answered Jan 29 '26 05:01

silent



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!