This is the documentation for Bamboo 5.5. View this page for the

Unknown macro: {spacejump}

of Bamboo, or visit the latest Bamboo documentation.

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).
  • Deployment variables are a number of standard reserved variables that are available during deployment executions. 
  • システム変数は Bamboo インスタンス全体にも適用され、同じ名前のシステム変数または環境変数から値を継承します。

You can generate variables of your own, using a similar format, however you cannot create a variable that is already in use by Bamboo. See Defining global variables and Defining plan variables.

How to use variables

変数を利用する

Variables can be used in all fields of a Task, with the exception of password variables. Variables can also be used with deployments.

${bamboo.variableName}

 

You can override a plan variable for a build, if you have triggered the build manually. For details, see  Triggering a plan build manually.

(warning) You cannot reference a variable from another variable in Bamboo, i.e. "double de-referencing". See this knowledge base article for more information.

Defining variables

Bamboo で独自の変数を定義する方法については、次の内容をご参照ください。

 

ビルド固有の変数

次のビルド固有の変数が初期設定で用意されています。

ビルド固有の変数

説明

bamboo.buildKey

現在のジョブのジョブ キー、"プロジェクト - 計画 - ジョブ" の形式、例: BAM-MAIN-JOBX

bamboo.buildResultKeyThe result key when this job executes, in the form PROJECT-PLAN-JOB-BUILD e.g. BAM-BOO-JOB1-8, where '8' is the build number. For deployment projects this variable will not have the JOB component e.g. PROJ-TP-6.
bamboo.buildResultsUrlジョブの実行終了後の Bamboo 内での結果 URL

bamboo.buildNumber

Bamboo のビルド番号、例: 123

bamboo.buildPlanName

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

bamboo.buildTimeStamp

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

bamboo.buildForceCleanCheckout

Whether the "Force Clean Build" option was used, values:true/false

bamboo.build.working.directory

The working directory that the build is being executed on

bamboo.ManualBuildTriggerReason.userNameThe user who triggered the manual build
一般的なリポジトリ変数 

bamboo.repository.revision.number

The revision number

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

bamboo.repository.previous.revision.number

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

Subversion 

bamboo.custom.svn.revision.number

The revision number

bamboo.custom.svn.lastchange.revision.number

The last changed revision number

bamboo.custom.svn.username

User name used for repository authentication

bamboo.repository.svn.repositoryUrl

The repository url

CVS 

bamboo.custom.cvs.last.update.time

The last updated timestamp

bamboo.custom.cvs.last.update.time.label

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 '_'

perforce 

bamboo.custom.p4.revision.number

The change set number

bamboo.custom.p4.username

User name used for repository authentication

bamboo.custom.p4.port

Port used for repository communication

bamboo.custom.p4.client

Client used for repository communication

Git 
bamboo.repository.git.branchブランチ
bamboo.repository.git.repositoryUrlThe repository url
Mercurial 

bamboo.repository.hg.repositoryUrl

The repository url

bamboo.repository.hg.branch

ブランチ

bamboo.repository.hg.username

User name used for repository authentication

システム変数は Bamboo インスタンス全体にも適用され、同じ名前のシステム変数または環境変数から値を継承します。

Build dependent variables

The following build dependent variables are also available:

ビルド固有の変数

説明

bamboo.dependency.parent.#

Allows a child build to query the build key of the triggering parent build, where # represents the position in the build tree - 0 at the top, 1 the following, and so on. The ${bamboo.dependency.parent.0} variable can be viewed in the child plan's metadata tab.

dependency.parent.total親ビルドの総数

デプロイ変数

Bamboo manages a number of standard reserved variables that are available during deployment executions. 

名前が繰り返される場合、次のリストで後にある変数が前の変数をオーバーライドします。

  • グローバル変数
  • 以下に定義されているリリース変数
  • 環境レベルで定義されたユーザー変数
  • 次の表の自動生成変数
変数説明
bamboo.agentIDThe id of the agent that the deployment is executed on.
bamboo.agentWorkingDirectoryエージェントの作業ディレクトリへのパス。これは Bamboo の作業ディレクトリとは異なります。
bamboo.build.working.directoryBamboo の作業ディレクトリへのパスです。これはビルド計画とデプロイ プロジェクトの両方で使用されます。
bamboo.deploy.environmentリリースがデプロイされる環境の名前。
bamboo.deploy.projectデプロイ プロジェクトの名前。
bamboo.deploy.rollbackデプロイされるリリースが置き換えられるリリースよりも古い場合に当てはまります。

bamboo.deploy.release

bamboo.deploy.version

デプロイされているリリースの名前。「.release」と「.version」のいずれかを使用できます。どちらもデプロイされるリリースの名前を返します。

bamboo.deploy.release.previous

bamboo.deploy.version.previous

The name of the release that is being replaced (if available). Either .release or .version can be used - both return the name of the release being replaced.
bamboo.resultsUrlThe URL to the screen in Bamboo that dispays build results.

You can generate variables of your own, using a similar format, however you cannot create a variable that is already in use by Bamboo. See Variables for deployment environments for more information on configuring your deployment environment variables.

Variables associated with releases

Bamboo では、デプロイ リリースに変数の次のタイプを使用できるようにしています。

変数説明
bamboo.buildNumberThe build result from which the release is created.
bamboo.buildResultKeyリリースが作成されたビルド結果のキー、例: KUNG-FOO-JOB1-35
bamboo.planKeyリリースに関連する計画のキー、例: KUNG-FOO
bamboo.planNameリリースに関連する計画の名前、例: Kung - Foo
リポジトリ 
bamboo.planRepository.<position>.branchNameThe name of the branch in the repository (depends on availability from the VCS used) e.g. default
bamboo.planRepository.<position>.name計画のリポジトリに表示されているリポジトリの名前、例: Mercurial
bamboo.planRepository.<position>.revisionThe revision use to build this release. Format depends on the VCS used.
bamboo.planRepository.<position>.typeリポジトリのタイプ、リポジトリ プラグインで定義されているとおり、例: hg、svn、git

In the variable names in the table above, <position> is the repository in the plan's repository list. It can be ignored for the first repository on the list; that is planRepository.name is equivalent to planRepository.1.name.

上記の表にある変数の一部は、実際にビルド計画に関連する変数であることにご注意ください。

System variables

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

${system.<variable>}

たとえば、システム変数 MYPATH=C:\MyPath; がある場合、システム変数と同じ値を継承する Bamboo システム変数 system.MYPATH を使用できます。

(info) Bamboo の古いバージョンでは、(スクリプト タスクの) "環境変数" フィールドで "PATH" を使用しても Windows の PATH 変数は設定されませんが、"Path" を使用すると cmd シェルで Path と PATH が設定されます。

bash で変数を使用する

Bamboo 変数は bash シェル変数としてエクスポートされます。すべてのフル ストップ (ピリオド) はアンダースコアに変換されます。たとえば、変数 bamboo.my.variable は、bash では $bamboo_my_variable になります。これはファイル スクリプト タスクに関連しています (インライン スクリプト タスクではありません)。

JIRA applications variables

Note that these variables can be accessed from a Bamboo build only when that build was triggered by releasing a version in a JIRA application.

Jira 変数説明
${bamboo.jira.baseUrl}The URL of your JIRA application server.
${bamboo.jira.projectKey}The key of the triggering JIRA application project.
${bamboo.jira.projectName}The name of the triggering JIRA application project.
${bamboo.jira.version}The release version of the triggering JIRA application project.
${bamboo.jira.username}リリース ビルドをトリガーしたユーザーのユーザー名

Maven の例

たとえば、Maven 2 バージョンを Bamboo で決定する場合、Maven 2 pom.xml が次のようになる可能性があります。

...
<groupId>com.atlassian.boo</groupId>
<artifactId>boo-test</artifactId>
<packaging>jar</packaging>
<version>1.1.${bambooBuildNumber}-SNAPSHOT</version>
...

その後、ビルド計画の "目標" フィールドに次を指定できます。

clean package -DbambooBuildNumber=${bamboo.buildNumber}

コマンドが実行されると、Bamboo は buildNumber を実際の番号 (1102 など) に置き換えます。この番号は、基盤となる Maven ビルドに渡されて使用されます。その後、コマンドは boo-test-1.1.1102-SNAPSHOT.jar ような jar を生成します。

Ant の例

その後、ビルド計画の "ターゲット" フィールドに次を指定できます。

-f build.xml -DbambooBuildNumber=${bamboo.buildNumber}

コマンドが実行されると、Bamboo は buildNumber を実際の番号 (1102 など) に置き換えます。この番号は、基盤となる Ant ビルドに渡されて使用されます。

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

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

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

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

  • システム機能は、こうしたフィールドすべてで使用できます (つまりグローバルとビルド固有)。
  • エージェント機能 (つまりエージェント固有と共有/サーバー機能) は、ビルド固有フィールドでのみ使用できます (つまりリポジトリ URLCVS ルート、またはブランチ名に使用できません)。

例:

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

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

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