Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are bamboo variables automatically available as environment variables?

I am trying to access Bamboo's variables as environment variables in my build script (PowerShell).

For example, this works fine in TeamCity

$buildNumber = "$env:BUILD_NUMBER"

And I expected this to work in Bamboo

$buildNumber = "$env:bamboo_buildNumber"
like image 809
Adam B Avatar asked Apr 13 '13 12:04

Adam B


People also ask

How do I access bamboo variables?

Plan variables can be accessed by using ${ bamboo. varName }. Plan variables can also be overridden at runtime when running a manual build. For more information, see Running a plan build manually.

How do I get bamboo variables in script?

For task configuration fields, use the syntax ${bamboo. myvariablename}. For inline scripts, variables are exposed as shell environment variables which can be accessed using the syntax $BAMBOO_MY_VARIABLE_NAME (Linux/Mac OS X) or %BAMBOO_MY_VARIABLE_NAME% (Windows).

How do I set a global variable in bamboo?

To access the Global variables page:From the top navigation bar select > Build resources > Global variables. Add, update, or delete the global variables, as desired: Add a new variable once you have entered the key and value for it. Updates to existing rows will be saved as you move between cells in the table.

What is Bamboo build working directory?

The Working Directory is where Bamboo temporarily puts the checked-out files it is building. The location of this directory was specified using the Setup Wizard, can be viewed as described in Bamboo's system information, and can be changed as described below.


1 Answers

Yes, Bamboo variables appear to be available automatically as environment variables in Bamboo 5.9.4. The following worked for me as an inline Powershell:

$revision = $Env:bamboo_planRepository_revision
$buildNumber = $Env:bamboo_buildNumber
$text = "$revision - $buildNumber"
$text > 'Version.txt'
like image 84
Thomas Langston Avatar answered Oct 16 '22 14:10

Thomas Langston