On this page:

Specifying Global, Build-specific or System Variables

When configuring a plan, you may want to specify variables to be used in the build process. There are three types of variables available to you:

The usage format for all global and build-specific variables is:

${bamboo.<variable>}

The usage format for all system variables is:

${system.<variable>}

e.g. 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.

Where can I use Global, Build-specific or System Variables?

Variables can be used in the following fields of your build plan:

Field

Available variables

Goal (for Maven builders only)
— see Specifying a Builder

Global variables
Build-specific variables
System variables

Build File (for Ant and NAnt builders only)
— see Specifying a Builder

Global variables
Build-specific variables
System variables

Target (for Ant and NAnt builders only)
— see Specifying a Builder

Global variables
Build-specific variables
System variables

Options (for NAnt builders only)
— see Specifying a Builder

Global variables
Build-specific variables
System variables

Script (for Scripts only)
— see Specifying a Builder

Global variables
Build-specific variables
System variables

Argument (for Scripts and Custom Commands only)
— see Specifying a Builder

Global variables
Build-specific variables
System variables

System Environment Variables
— see Specifying a Builder

Global variables
Build-specific variables
System variables

Repository URL (for Subversion repositories only)
— see Specifying the Source Repository for a Plan

Global variables
System variables

Web Repository URL (for Subversion, CVS and Perforce repositories)
— see Specifying the Source Repository for a Plan

Global variables
System variables

CVS Root (for CVS repositories only)
— see Specifying the Source Repository for a Plan

Global variables
System variables

Branch name (for CVS repositories only)
— see Specifying the Source Repository for a Plan

Global variables
System variables


Maven example 

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.

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.

Using 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:

${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.

What Capabilities Can I Use Where?

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:

  1. Set the following as a system environment variable field on the 'Builder' tab:
    ${bamboo.capability.thatsystemvariable}
  2. 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.