Search code examples
tfs-2015azure-pipelines

TFS Buildnumber how to sync with environment variable?


According to documentation : https://msdn.microsoft.com/en-us/library/vs/alm/build/scripts/variables

It should be possible to persist the build value inside an environment variable:

Build.BuildNumber (BUILD_BUILDNUMBER)

I've created this environment variable, now I want to persist a value there, so I've set it to, for example: 1.0.0.1

How can I get the Build number format in general tab to sync to the environment variable?


Solution

  • The build service only use the Environment variable when the variable value is blank:

    Environment variables on the agent. If variables is referenced and there is no value specified we will use Environment variables to try and fill in the value.

    However, Build.BuildNumber variable is filled with value as soon as the build starts. So there isn't any way to do this for Build.BuildNumber variable.