Index![]()
Downloads (PDF, HTML & XML formats)
[Bamboo Knowledge Base Home]
Documentation for Bamboo 4.0.x. Documentation for earlier versions of Bamboo is available too. 
![]()
Variables can be used to set static values that are used when building plans in Bamboo.
On this page:
See Defining global variables for information on defining global variables.
The usage format for all global variables is:
${bamboo.globalVarName}
See Defining plan variables for information on defining plan variables. You can override a plan variable for a build, if you have triggered the build manually. For details, see Triggering a plan Build Manually.
The usage format for all plan variables is:
${bamboo.varName}
The following build-specific variables are also available by default:
Build-specific variable | Source | Description |
|---|---|---|
buildKey | Bamboo property | The plan key for the current job, e.g. |
buildNumber | Bamboo property | The Bamboo build number, e.g. |
buildPlanName | Bamboo property | The Bamboo plan name e.g. |
buildTimeStamp | Bamboo property | The time when build was started in ISO 8601 format |
buildForceCleanCheckout | Bamboo property | Whether the "Force Clean Build" option was used, values:true/false |
build.working.directory | Bamboo property | The working directory that the build is being executed on |
| manualBuildTriggerReason.username | Bamboo property | The user who triggered the manual build |
repository.revision.number | Plugin | The revision number |
repository.previous.revision.number | Plugin | The previous revision number (might not exist if for example is initial build) |
custom.svn.revision.number | Plugin | (For Subversion only) The revision number |
custom.svn.lastchange.revision.number | Plugin | (For Subversion only) The last changed revision number |
custom.svn.username | Plugin | (For Subversion only) User name used for repository authentication |
repository.svn.repositoryUrl |
| (For Subversion only) The repository url |
custom.cvs.last.update.time | Plugin | (For CVS only) The last updated timestamp |
custom.cvs.last.update.time.label | Plugin | (For CVS only) The last updated timestamp to be used as a label for post build result labelling. The spaces in the cvs version string are replaced with '_' |
custom.p4.revision.number | Plugin | (For Perforce only) The change set number |
custom.p4.username | Plugin | (For Perforce only) User name used for repository authentication |
custom.p4.port | Plugin | (For Perforce only) Port used for repository communication |
custom.p4.client | Plugin | (For Perforce only) Client used for repository communication |
repository.hg.repositoryUrl |
| (For Mercurial only) The repository url |
repository.hg.branch |
| (For Mercurial only) The branch |
repository.hg.username |
| (For Mercurial only) User name used for repository authentication |
The usage format for all build-specific variables is:
${bamboo.varName}
The usage format for all system variables is:
${system.<variable>}
For example, if you have a system variable MYPATH=C:\MyPath; you can use a Bamboo system variable system.MYPATH which will inherit the same value as the system variable.
Variables can be used in the following fields of your build plan:
Field | Global | Build-specific | System |
|---|---|---|---|
Goal (for Maven builders only) | |||
Build File (for Ant and NAnt builders only) | |||
Target (for Ant and NAnt builders only) | |||
Options (for NAnt builders only) | |||
Script (for Scripts only) | |||
Argument (for Scripts and Custom Commands only) | |||
Environment Variables | |||
Repository URL (for Subversion repositories only) | |||
Web Repository URL (for Subversion, CVS and Perforce repositories) | |||
CVS Root (for CVS repositories only) | |||
Branch name (for CVS repositories only) |
For example, you may want your Maven 2 version to be determined by Bamboo. In Maven 2 pom.xml you may have:
...
<groupId>com.atlassian.boo</groupId>
<artifactId>boo-test</artifactId>
<packaging>jar</packaging>
<version>1.1.${env.bambooBuildNumber}-SNAPSHOT</version>
...
You can then specify the following in the Goal field of your build plan:
clean package -DbambooBuildNumber=${bamboo.buildNumber}
When the command runs, Bamboo will replace the buildNumber with the actual number (e.g. 1102), which will be passed to the underlying Maven build to use. The command will then produce a jar that looks like this: boo-test-1.1.1102-SNAPSHOT.jar.
You can then specify the following in the Target field of your build plan:
-f build.xml -DbambooBuildNumber=${bamboo.buildNumber}
When the command runs, Bamboo will replace the buildNumber with the actual number (e.g. 1102), which will be passed to the underlying Ant build to use.
You can also specify a capability to be used in a similar way to a global variable.
The format of the capability should be as follows:
${bamboo.capability.<capability_key>}
For example,
Custom
${bamboo.capability.<capability_key>}
JDK
${bamboo.capability.system.jdk.<jdk_label>}
Builder
${bamboo.capability.system.builder.<builder_type>.<builder_label>}
e.g. ${bamboo.capability.system.build.maven.Maven1}
Perforce
${bamboo.capability.system.p4Executable}
If you click on a capability, the specific capability key will be contained in the URL.
Please note, the space characters in the URL will be replaced with '+' characters. We recommend that you do not use capability labels with space characters, if you wish to use them as variables. A possible solution for space characters is to format them with '${}' symbols, however, this does not work in all cases.
Global and Build-Specific Variables can be used in a specific fields of your build plan, as specified above. For capabilities,
For example,
If you wanted to specify a system variable, but have it set to different values on each agent, do the following:
Set the following as a system environment variable field on the Builder tab:
${bamboo.capability.thatsystemvariable}
24 Comments
Anonymous
Mar 12, 2009Which variable should I use in order to find the current build directory?
Anonymous
Sept 24, 2011build directory - ${bamboo.projectBaseDir}
I beleive this is from Bamboo, not a plugin.
Anonymous
Sept 24, 2011${bamboo.projectBaseDir} doesn't seem to work on 2.6. I really need access to this variable though. Any other suggestions?
AjayA
Jul 09, 2010Folks,
The {bamboo.projectBaseDir} variable is actually provided by the Bamboo pre/post build plugin:
https://studio.plugins.atlassian.com/wiki/display/BPBC/Home
Can you try installing this plugin?
Cheers,
Ajay.
Robert Crosbie
Aug 06, 2010For those who don't want to use the pre/post plugin, you can construct the build directory yourself.
Create a custom capability on your agent(s) called build-dir. For example:
build-dir = C:\bamboo\xml-data\build-dir
In your build plans you can use build-dir and buildKey to construct the project build directory: For example:
BUILDROOT=${bamboo.capability.build-dir}\${bamboo.buildKey}I still think Bamboo should provide a build directory variable by default though.
Jared Morrow
Nov 12, 2010Thanks for your comment, you are a life saver. I tried using the variable buildWorkingDir that was listed elsewhere in the documentation with no luck, so I'm sure glad I got pointed to this page to see your comment. I agree, I think there should be a default variable for working directory because I can see that being one of the most often used ones.
Anonymous
Apr 02, 2009Is there an explicit list somewhere of the Bamboo variables?
Ulrich Kuhnhardt
May 26, 2009The available variables are listed above. If you need other variables that represent bamboo parameters you can make them available via a plugin and persist them as custom.<my-variable>.
Anonymous
Oct 06, 2009Could I possibly get an nant example? And is there anything special to be done in order to pass values back to Bamboo?
xavier lannoye
Jan 28, 2010Hi
I cannot access bamboo.custom.svn.revision.number varaible in my ant scripts.
any suggestion welcome
regards
Alan Farkas
Sept 24, 2011Are you passing the variable into your Ant script via the Bamboo Builder Panel?
ex: svn.rev.num="${bamboo.custom.svn.revision.number}"
In your ant script, you would reference this variable as such:
"${env.svn.rev.num}"
xavier lannoye
Feb 09, 2010Hi
I finally got it work using this way:
in the builder tab, add the following parameter to the ant script (in "target" field)
-Dmy.svn.revision=${bamboo.custom.svn.revision.number}then in my ant script I can reference those variable using
et voilà
regards
user-4cc9e
Aug 27, 2010Hi,
Is-it possible to know the current user (how is executing the build) via the build-specific variables?
I try to use the builder 'ant' to send an email on behalf of this user...
Thanks,
Bruno
user-4cc9e
Aug 27, 2010I did the following test: Send an email with substitution
1. I have a plan with ant as builder.
2. System Env Variables: -Dmy.bamboo.buildKey=${bamboo.buildKey} -Dmy.bamboo.buildNumber=${bamboo.buildNumber} -Dmy.bamboo.buildPlanName=${bamboo.buildPlanName} -Dmy.bamboo.buildTimeStamp=${bamboo.buildTimeStamp}
3. build.xml
<project name="My Build" default="war" basedir="."> <target name="init"> <property file="build.properties" /> <property environment="env" /> </target> <target name="request" depends="init" description="Send an email with bamboo vars"> <mail from="me@company.com" tolist="me@company.com" messagefile="Test.txt" subject="Test var bamboo"/> </target> </project>4. Test.txt
Testing bamboo variables bamboo.buildKey = ${env.my.bamboo.buildKey} bamboo.buildNumber = ${env.my.bamboo.buildNumber} bamboo.buildPlanName = ${env.my.bamboo.buildPlanName} bamboo.buildTimeStamp = ${env.my.bamboo.buildTimeStamp}5. Result
Testing bamboo variables bamboo.buildKey = SDBX-SDBX bamboo.buildNumber = 12 bamboo.buildPlanName = ${bamboo.buildPlanName} bamboo.buildTimeStamp = ${bamboo.buildTimeStamp}7. Remarks
Only buildKey and buildNumber are replaced by their value.
Is-it a bug or one undocumented feature?
We use bamboo version 2.4.2 build 1602
user-4cc9e
Aug 27, 2010Anonymous
Sept 24, 2011In the bamboo I am entering
cmcc_opts="D:/myworkspace" in the system variables. I am trying to fetch the variable from ant as ${system.cmcc_opts}
But this is not returning me the correct result. Please suggest me some solution
Anonymous
Jan 19, 2011It would be nice if the table had a column about which Bamboo versions support the variable. It seems my current version does not have "custom.svn.lastchange.revision.number"...
Anonymous
Feb 16, 2011The buildKey now gives the composite plan-job name, not the plan name.
e.g. "<myplan>-JOB1" by default
It would be good if we could still get the actual plan name.
Jared Morrow
Mar 15, 2011If documentation isn't kept up-to-date and isn't correct for many versions of the tool, what is the point of the documentation?
Is there a way to get JUST the plan name?
buildPlanName returns "Some Project name - Some plan name" and I need ONLY the plan name.
Anonymous
Jul 07, 2011Hi, What is the bamboo property represent current user logged in? I want to pass the property to ant script to let the ant script know who is running the script. thanks very much
Chris Ferry
Sept 20, 2011Can someone at Atlassian answer this? I, as well, need to pass the "current user" value to an external script to notify users who has executed the build plan.
PiotrA
Sept 20, 2011Check this out: https://jira.atlassian.com/browse/BAM-7334
I reckon the feature you ask for will be (or is already?) implemented in the incoming Bamboo 3.3. I don't think it was possible in the older Bamboo versions to pass the "current user" value to the external scripts without some kind of external plugin...
Jan Swaelens
Jan 13, 2012I am looking to implement a link to the bamboo build page inside our application, to allow users to easily see what issues are fixed in the build and which features are added ...
Is there a way to get to the actual bamboo root URL? With that I can manage to add the other path parts up to the relevant plan & build number.
The only thing I can think of is define the root URL as a global variable, but wouldn't it be nice to have this built in?
thanks
Aaron Evans
Apr 13, 2012How can you access Bamboo plan or global variables from a shell script task?