All Versions
Bamboo 5.13Bamboo 5.7.x
Bamboo 5.6.x
More...
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 | Available variables |
|---|---|
Goal (for Maven builders only) | Global variables |
Build File (for Ant and NAnt builders only) | Global variables |
Target (for Ant and NAnt builders only) | Global variables |
Options (for NAnt builders only) | Global variables |
Script (for Scripts only) | Global variables |
Argument (for Scripts and Custom Commands only) | Global variables |
System Environment Variables | Global variables |
Repository URL (for Subversion repositories only) | Global variables |
Web Repository URL (for Subversion, CVS and Perforce repositories) | Global variables |
CVS Root (for CVS repositories only) | Global variables |
Branch name (for CVS repositories only) | Global variables |
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}
Defining Global Variables
Defining Plan Variables
Triggering a Plan Build Manually
Configuring Plugins