Variables can be used to set static values that are used when building plans in Bamboo.
|
Specifying variables
Global variables
See Defining global variables for information on defining global variables.
The usage format for all global variables is:
Plan variables
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:
Build-specific variables
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 |
- System variables also apply across your entire Bamboo instance and inherit their values from system or environment variables of the same name.
The usage format for all build-specific variables is:
System variables
The usage format for all system variables is:
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.
Using variables
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) |
|
Examples of variables usage
Maven example
For example, you may want your Maven 2 version to be determined by Bamboo. In Maven 2 pom.xml you may have:
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.
Ant example
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.
Specifying capabilities as variables
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:
For example,
Custom
JDK
Builder
Perforce
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.
Using capabilities
Global and Build-Specific Variables can be used in a specific fields of your build plan, as specified above. For capabilities,
- System Capabilities are available to all of these fields, (i.e. global and build-specific).
- Agent Capabilities (i.e. agent-specific and shared/server capabilities) are available only to the build-specific fields. (i.e. not available to Repository URL, CVS Root or Branch name.)
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:
- Specify the system environment variable as a custom capability on each of your agents, and set to the capability to the different values, as desired.







24 Comments
Hide/Show CommentsMar 12, 2009
Anonymous
Which variable should I use in order to find the current build directory?
Sep 24, 2011
Anonymous
build directory - ${bamboo.projectBaseDir}
I beleive this is from Bamboo, not a plugin.
Sep 24, 2011
Anonymous
${bamboo.projectBaseDir} doesn't seem to work on 2.6. I really need access to this variable though. Any other suggestions?
Jul 09, 2010
Ajay Sridhar
Folks,
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.
Aug 06, 2010
Robert Crosbie
For 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:
I still think Bamboo should provide a build directory variable by default though.
Nov 12, 2010
Jared Morrow
Thanks 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.
Apr 01, 2009
Anonymous
Is there an explicit list somewhere of the Bamboo variables?
May 25, 2009
Ulrich Kuhnhardt
The 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>.
Oct 05, 2009
Anonymous
Could I possibly get an nant example? And is there anything special to be done in order to pass values back to Bamboo?
Jan 28, 2010
lannoye xavier
Hi
I cannot access bamboo.custom.svn.revision.number varaible in my ant scripts.
any suggestion welcome
regards
Sep 24, 2011
Alan Farkas
Are 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}"
Feb 09, 2010
lannoye xavier
Hi
I finally got it work using this way:
in the builder tab, add the following parameter to the ant script (in "target" field)
then in my ant script I can reference those variable using
et voilà
regards
Aug 27, 2010
Bruno Blaise
Hi,
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
Aug 27, 2010
Bruno Blaise
I 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
4. Test.txt
5. Result
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
Aug 27, 2010
Bruno Blaise
Sep 24, 2011
Anonymous
In 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
Jan 19, 2011
Anonymous
It 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"...
Feb 15, 2011
Anonymous
The 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.
Mar 15, 2011
Jared Morrow
If 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.
Jul 07, 2011
Anonymous
Hi, 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
Sep 20, 2011
Chris Ferry
Can 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.
Sep 20, 2011
Piotr Stefan Stefaniak [Atlassian]
Check 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 13, 2012
Jan Swaelens
I 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
Apr 13, 2012
Aaron Evans
How can you access Bamboo plan or global variables from a shell script task?
Add Comment