Mr. Robot
Mr. Robot

Reputation: 1824

Cannot access build number in Azure Devops pipeline bash script

I have this line of code in bash script in my Azure Devops pipeline:

cat <(printf " \n") <(echo $version $env:BUILD_BUILDNUMBER $current_date) <(tail -n+7 changelog-update.md) ./CHANGELOG.md > output 

The output it prints however looks like this:

Version: :BUILD_BUILDNUMBER Thu Oct 1 18:29:19 CEST 2020

How can I access the build number of the build in the pipeline?

Upvotes: 1

Views: 1266

Answers (1)

Matt
Matt

Reputation: 4045

This is probably an issue with how you are referencing the variable. Take a look at the documentation on how to access variables through the environment.

Notice that variables are also made available to scripts through environment variables. The syntax for using these environment variables depends on the scripting language.

The name is upper-cased, and the . is replaced with the _. This is automatically inserted into the process environment. Here are some examples:

  • Batch script: %VARIABLE_NAME%
  • PowerShell script: $env:VARIABLE_NAME
  • Bash script: $VARIABLE_NAME

Upvotes: 2

Related Questions