Documentation for Bamboo 4.3.x. Documentation for other versions of Bamboo is available too.

Variables can be used to set static values that are used when building plans in Bamboo.

  • Global variables are defined across your entire Bamboo instance, and have the same (static) value for every plan that is built by Bamboo. .
  • Plan variables are similar to global variables, but are defined for specific plans. Plan variables override global variables with the same name. You can also override a plan variable for a build, if you have triggered the build manually.
  • Build-specific variables are evaluated by Bamboo dynamically at build time. The source of a build-specific variable can either be a Bamboo property or one of the default plugins (assuming they have been enabled).
  • システム変数は Bamboo インスタンス全体にも適用され、同じ名前のシステム変数または環境変数から値を継承します。

Specifying variables

Global variables

See Defining global variables for information on defining global variables.

The usage format for all global variables is:

${bamboo.globalVarName}

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:

${bamboo.varName}

ビルド固有の変数

The following build-specific variables are also available by default:

ビルド固有の変数

ソース

説明

buildKey

Bamboo property

The job key for the current job in the form PROJECT-PLAN-JOB, e.g. BAM-MAIN-JOBX

buildNumber

Bamboo property

Bamboo のビルド番号、例: 123

buildPlanName

Bamboo property

The Bamboo plan name e.g. Some Project name - Some plan name

buildTimeStamp

Bamboo property

ビルドが開始された時刻、ISO 8601 形式、例: 2010-01-01T01:00:00.000+01:00

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.userNameBamboo propertyThe user who triggered the manual build

repository.revision.number

プラグイン

The revision number

repository.branch.name The repository branch name (for Bamboo version 4.2 or later)

repository.previous.revision.number

プラグイン

The previous revision number (might not exist if for example is initial build)

custom.svn.revision.number

プラグイン

(For Subversion only) The revision number

custom.svn.lastchange.revision.number

プラグイン

(For Subversion only) The last changed revision number

custom.svn.username

プラグイン

(For Subversion only) User name used for repository authentication

repository.svn.repositoryUrl

 

(For Subversion only) The repository url

custom.cvs.last.update.time

プラグイン

(For CVS only) The last updated timestamp

custom.cvs.last.update.time.label

プラグイン

(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

プラグイン

(For Perforce only) The change set number

custom.p4.username

プラグイン

(For Perforce only) User name used for repository authentication

custom.p4.port

プラグイン

(For Perforce only) Port used for repository communication

custom.p4.client

プラグイン

(For Perforce only) Client used for repository communication

repository.git.branch (For Git only) The branch

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:

${bamboo.varName}

System variables

すべてのシステム変数に使用される形式は次のとおりです。

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

フィールド

グローバル

Build-specificシステム

Goal (for Maven builders only)
— see Configuring tasks

(tick)

(tick)(tick)

Build File (for Ant and NAnt builders only)
— see Configuring tasks

(tick)

(tick)(tick)

Target (for Ant and NAnt builders only)
— see Configuring tasks

(tick)

(tick)(tick)

Options (for NAnt builders only)
— see Configuring tasks

(tick)

(tick)(tick)

Script (for Scripts only)
— see Configuring tasks

(tick)

(tick)(tick)

Argument (for Scripts and Custom Commands only)
— see Configuring tasks

(tick)

(tick)(tick)

Environment Variables
— see Configuring tasks

(tick)

(tick)(tick)

Repository URL (for Subversion repositories only)
— see Specifying the source repository

(tick)

(error)(tick)

Web Repository URL (for Subversion, CVS and Perforce repositories)
— see Specifying the source repository

(tick)(error)(tick)

CVS Root (for CVS repositories only)
— see Specifying the source repository

(tick)

(error)(tick)

Branch name (for CVS repositories only)
— see Specifying the source repository

(tick)

(error)(tick)

 

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:

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

機能を変数として指定する

グローバル変数と同じ方法で使用する機能を指定することもできます。

機能の形式は次のようにする必要があります。

${bamboo.capability.<capability_key>}

例:

  • カスタム

    ${bamboo.capability.<capability_key>}
  • JDK

    ${bamboo.capability.system.jdk.<jdk_label>}
  • ビルダー

    ${bamboo.capability.system.builder.<builder_type>.<builder_label>}
    e.g. ${bamboo.capability.system.build.maven.Maven1}
  • perforce

    ${bamboo.capability.system.p4Executable}

機能をクリックすると、特定の機能キーが URL に含まれます。

URL のスペース文字は "+" の文字に置き換わります。変数として使用する場合は、スペース文字を含む機能ラベルを使用しないことをお勧めします。スペース文字の考えられる解決策は、「${}」記号でフォーマットすることですが、すべての場合にうまくいくわけではありません。

機能を使用する

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.)

例:

システム変数を指定しようとしているが、エージェントごとに異なる値を設定する場合は、次の手順を実行してください。

  1. [ビルダー] タブのシステム環境変数フィールドとして次を設定します。

    ${bamboo.capability.thatsystemvariable}
  2. システム環境変数を各エージェントのカスタム機能として指定し、必要に応じて機能を異なる値に設定します。