Bitbucket is getting a new navigation

We’re rolling out these changes, so the documentation may not match your experience in the Bitbucket Cloud app. Read about the new Bitbucket navigation

ステップ オプション

これらのオプションは、コンパイラーやテストの実行など、コマンドとスクリプトを実行するために使用される必須の script プロパティを含め、パイプラインのステップを定義するために使用されます。

パイプラインのステップ オプション

ステップは、次のオプションを受け入れます。

ステップのプロパティ

step オプションは、ビルドの実行単位を定義するために使用されます。ステップは、bitbucket-pipelines.yml ファイルに表示される順序で実行されます。1 つのパイプラインに、最大 100 のステップを含められます。

パイプラインの各ステップは個別の Docker コンテナーを起動し、script オプションで構成されたコマンドを実行します。各ステップは、次のようなオプションを使用してカスタマイズできます。

  • runtime – ステップのランタイム環境をカスタマイズします。

    • cloud

    • atlassian-ip-ranges

  • image — 別の Docker イメージを使用するため。

  • max-time — ステップの許容最大時間を設定するため。

  • cachesservices — 特定のキャッシュとサービス用。

  • artifacts — 後続のステップが使用できるアーティファクトを保持します。

  • clone — ステップの Git クローン操作をカスタマイズするため。

  • trigger — パイプラインを続行する前に手動にする必要がある場合に、ステップを manual に設定するため。

プロパティstep

必須 — はい

Data type — Block of new-line separated key-value pairs (YAML spec - Block Mapping)

Allowed parent propertiesbranches, custom, default, pull-requests, steps, and tags.

Allowed child properties — Requires the script property. The following properties are optional: after-script, artifacts, caches, clone, condition, deployment, fail-fast, image, name, oidc, runs-on, runtime, services, size, and trigger.

例 — 単一ステップを使用したパイプライン

pipelines: default: - step: script: - echo "Hello, World!"

例 — 連続および並行ステップを使用したパイプライン

pipelines: default: - step: # sequential step name: Build script: - ./build.sh - step: # sequential step name: Build script: - ./build.sh - parallel: # these 2 steps will run in parallel steps: - step: name: Integration 1 script: - ./integration-tests.sh --batch 1 - step: name: Integration 2 script: - ./integration-tests.sh --batch 2 - step: # non-parallel step script: - ./deploy.sh

type プロパティ

type プロパティは、ステップのタイプを指定するために使用されます。既定値は、通常のインライン ステップを表す type: inline です。type: inline プロパティ以外に、子パイプライン (パイプライン内で実行されるパイプライン) をトリガーするために使用される type: pipeline プロパティがあります。

See Child pipeline step options for details of pipeline steps.

プロパティtype

必須 — いいえ (既定値は type:inline)

データ タイプinline または pipeline のいずれか

Allowed parent propertiesstep

指定可能な子プロパティなし

script プロパティ

スクリプト

script プロパティは、step に対して実行されるコマンドのリストを指定するために使用されます。コマンドのリストは、コマンド間の自動クリーンアップ操作なしで、リストされている順序で実行されます。大規模なスクリプトは個別のスクリプト ファイルに移動し、それらを bitbucket-pipelines.yml から呼び出すことをお勧めします。

プロパティscript

必須 — いいえ (type = inline の場合にのみ必須)

Data type — A list of Strings and/or pipe properties (YAML spec - Sequence)

Allowed parent propertiesstep

Allowed child propertiespipe (optional)

例 — script プロパティを使用して、基本的なコマンドを実行する

pipelines: default: - step: script: - echo "Hello, World!"

例 — script プロパティと個別のファイルを併用して、大規模なスクリプトを実行する

pipelines: default: - step: script: - ./long-build-script.sh

例 — script プロパティを使用して、単一のステップに対して一連のコマンドを実行する

pipelines: default: - step: script: - echo "Hello," - echo "World!" - ./build.sh

例 — script と pipe プロパティを併用して、パイプを実行する

pipelines: default: - step: name: Alert Opsgenie script: - echo "Sending an alert through Opsgenie" - pipe: atlassian/opsgenie-send-alert:latest variables: GENIE_KEY: $GENIE_KEY MESSAGE: "Danger, Will Robinson!" DESCRIPTION: "An Opsgenie alert sent from Bitbucket Pipelines" SOURCE: "Bitbucket Pipelines" PRIORITY: "P1"

一般的なオプション

max-time

max-time オプションは、タイムアウトする前にステップを実行できる最大時間 (分単位) を設定します。max-time オプションは、グローバル options プロパティと個々のパイプライン ステップの両方で設定できます。パイプライン ステップの既定の最大時間は 120 分です。

プロパティmax-time

必須 — いいえ

データ タイプ — 整数

指定可能な値1720 の正の整数

既定値120

Allowed parent propertiesoptions and step

例 — max-time オプションを使用して、パイプラインの各ステップに指定可能な最大時間を設定する

options: max-time: 30 pipelines: default: - step: name: Sleeping step script: - sleep 120m # This step will timeout after 30 minutes

例 — max-time オプションを使用して、パイプラインの個別のステップに指定可能な最大時間を設定する

options: max-time: 60 pipelines: default: - step: name: Sleeping step script: - sleep 120m # This step will timeout after 60 minutes - step: name: quick step max-time: 5 script: - sleep 120m # This step will timeout after 5 minutes

サイズ

size オプションは、Bitbucket Cloud インフラストラクチャまたは Linux Docker セルフホストランナーで実行する場合、ステップまたはパイプライン全体に追加のリソースを割り当てます。

このオプションは、ホストマシン上で利用可能なすべてのリソースを使用する Windows PowerShell、macOS シェル、Linux シェルランナーなどのシェルベースのランナーには影響しません。

デフォルトでは、Bitbucket Cloud インフラストラクチャまたは Linux Docker セルフホスト ランナー上で実行されるステップは、ボリュームをマウントするために、4GB のメモリ、4 つの CPU (他のタスクと共有される場合があります)、step あたり 64 GB のディスク容量にアクセスできます。

2x のサイズを指定すると、step またはパイプラインの空きメモリは 2 倍になります。割り当てられたメモリは stepscriptstep.services の両方で共有されることに注意してください。

4x を超える size オプションを選択すると、追加の CPU リソースとディスク容量も確保されます。step4x 以上の size が割り当てられていると、該当する数の CPU への専用アクセスが保証され、ボリュームをマウントするためのより多くのディスク容量が得られます。

4x ステップは 1x ステップのビルド時間の 4 倍を、2x ステップは 1x ステップのビルド時間の 2 倍を使用します。注意: ビルド時間を増やすと、パイプライン ビルドの現在のコストも増加する可能性があります。

サイズに基づくリソース割り当て

サイズ

CPU

メモリ

ボリューム サイズ

1x

2

4

64 ギガバイト

2x

4

8

64 ギガバイト

4x

8

16

256 ギガバイト

8x

16

32

256 ギガバイト

16x

32

64

256 ギガバイト

24x

48

96

256 ギガバイト

32x

64

128

256 ギガバイト

プロパティsize

必須 — いいえ

データ タイプ — 文字列

指定可能な値 — 次のいずれか:

  • 1x, 2x, 4x, 8x, 16x, 24x or 32x for pipeline steps run on Bitbucket Cloud.

4x, 8x, 16x, 24x, and 32x pipelines size options are only available for builds running on a paid Bitbucket Cloud plan (Standard or Premium).

既定値1x

Allowed parent propertiesoptions and step

例 — size オプションを使用して、すべてのパイプライン ステップで利用可能なメモリを増やす

options: size: 2x pipelines: default: - step: script: - echo "2x memory is probably not needed for an echo command"

例 — size オプションを使用して、パイプライン ステップで利用可能なメモリを増やす

pipelines: default: - step: size: 2x script: - echo "This step gets double the memory!"

ランタイム

ステップに適用されるランタイム設定です。

プロパティruntime

必須 — いいえ

Data type — Block of new-line separated key-value pairs (YAML spec - Block Mapping)

指定可能な親プロパティoptions と step

指定可能な子プロパティcloud (必須)

例 - ランタイムを使用して、4x、8x、および 16x のすべてのステップで atlassian-ip-ranges を、すべてのステップで arm を有効にする

options: runtime: cloud: atlassian-ip-ranges: true arch: arm pipelines: default: - step: size: 4x script: - echo "I use atlassian-ip-ranges"

例 - ランタイムを使用して、特定のステップで atlassian-ip-rangesarm を有効にする

pipelines: default: - step: size: 4x runtime: cloud: atlassian-ip-ranges: true arch: arm script: - echo "I use atlassian-ip-ranges"

 

クラウド ランタイム設定

クラウド ステップに適用されるランタイム設定です。

プロパティcloud

必須 — いいえ

Data type — Block of new-line separated key-value pairs (YAML spec - Block Mapping)

指定可能な親プロパティruntime

指定可能な子プロパティatlassian-ip-ranges (オプション)、arch (オプション)

クラウド ランタイム設定用のアトラシアン IP 範囲

This option indicates whether to use the default aws-ip-ranges or the atlassian-ip-ranges when executing your step for ingress/egress traffic.

プロパティatlassian-ip-ranges

必須 — いいえ

データ タイプ — ブール値

指定可能な値true または false

既定値false

指定可能な親プロパティcloud

クラウド ランタイム設定のアーキテクチャ

このオプションは、ステップを実行するときに使用するアーキテクチャを制御します

プロパティarch

必須 — いいえ

データ タイプ — 文字列

指定可能な値arm または x86

既定値x86

指定可能な親プロパティcloud

arm オプションは、Bitbucket Cloud の Standard または Premium プランで実行されているビルドでのみ利用できます。

after-script

The after-script option lists the commands that will run after the script in the step is completed, regardless of whether the script succeeds or fails. This could be useful for clean up commands, test coverage, notifications, or rollbacks you might want to run. The BITBUCKET_EXIT_CODE pipeline variable can be used to determine if the script in the step has succeed or failed.

after-script のコマンドが失敗した場合

  • ステップの after-script にリストされたそれ以降のコマンドは実行されません。

  • ステップに対して報告されているステータスには影響しません。

プロパティafter-script

必須 — いいえ

Data type — A list of Strings and/or pipe properties (YAML spec - Sequence)

Allowed parent propertiesstep

Allowed child propertiespipe (optional)

例 — after-script オプションを使用して、script コマンドの後にコマンドを実行する

pipelines: default: - step: name: Build and test script: - npm install - npm test after-script: - echo "after script has run!"

名前

step または stage の名前。名前は、Bitbucket Pipelines のログと Bitbucket UI に表示されます。名前は (パイプライン内で) 一意であり、ステージ内のステップを説明するものでなければなりません。

プロパティname

必須 — いいえ

データ タイプ — 文字列

Allowed parent propertiesstep and stage

例 - name を使用して 1 つのステージと 2 つのステップにラベルを付ける

pipelines: default: - stage: name: Build and test steps: - step: name: Build app script: - sh ./build-app.sh - step: name: Run unit tests script: - sh ./run-tests.sh - step: script: - pipe: atlassian/slack-notify:latest variables: WEBHOOK_URL: $SLACK_WEBHOOK PRETEXT: 'Hello, Slack!' MESSAGE: 'Hello, Slack!!'

フェイル ファスト

fail-fast は、すべての parallel ステップに適用することもできれば、並行ステップの特定の step に適用することもできます。

  • ステップに fail-fast: false が含まれる場合、並行グループ全体が停止することなく、ステップが失敗することがあります。

  • ステップに fail-fast: true が含まれる場合、ステップが失敗すると、並行グループ全体が停止します。

プロパティfail-fast

必須 — いいえ

データ タイプ — ブール値

指定可能な値true または false

既定値false

Allowed parent propertiesstep and parallel

例 — fail-fast を使用して、いずれかのステップが失敗した時点で並行ステップを停止する

pipelines: default: - step: name: Build script: - ./build.sh - parallel: # this option allows a force stop on all running steps if any step fails fail-fast: true steps: - step: name: Integration 1 script: - ./integration-tests.sh --batch 1 - step: name: Integration 2 script: - ./integration-tests.sh --batch 2

例 — fail-fast から並行ステップを除外する

pipelines: default: - step: name: Build script: - ./build.sh - parallel: # this option allows a force stop on all running steps if any step fails fail-fast: true steps: - step: name: Integration 1 script: - ./integration-tests.sh --batch 1 - step: name: Integration 2 script: - ./integration-tests.sh --batch 2 - step: # option can be disabled for a step # and its failure won't stop other steps in a group fail-fast: false name: Upload metadata script: - ./upload-metadata.sh

on-fail

on-fail オプションはデプロイ段階/ステップでは使用できません。

on-fail オプションでは、失敗したステップを Bitbucket Pipelines でどのように処理するかをカスタマイズできます。strategy フィールドを使用して動作を設定できます。次の 2 つの戦略があります。

  • strategy: fail: この戦略が設定されたステップが失敗すると、パイプライン全体が停止し、失敗とマークされます。これは既定の戦略で、何も指定しない場合は自動的にこの戦略が使用されます。

  • strategy: retry: この戦略が設定されたステップが失敗すると、そのステップは自動的に再試行されます。この戦略では、on-fail に次のオプションが追加されます。

    • maxRetryCount: 最大再試行回数を制限するオプションの値。1 から 10 までの整数を指定できます。値を指定しない場合の既定値は 1 です。

  • strategy: ignore: この戦略が設定されたステップが失敗した場合、そのステップは UI で「失敗」とマークされますが、パイプライン全体では失敗は無視され、残りのステップは引き続き実行されます。ignore 戦略を使用したステップが失敗しても、パイプライン全体は失敗とはなりません

並行グループに関する注意事項: fail 戦略のみが fail-fast と互換性があります。ignore および retry 戦略は、同じステップ、また同じ並行グループ内の他の並行ステップに fail-fast がある場合は無効になります。

プロパティon-fail

必須 — いいえ

Data type — Block of new-line separated key-value pairs (YAML spec - Block Mapping)

Allowed parent propertiesstep, parallel, and stage.

例 — on-fail を使用してステップの失敗を無視する

pipelines: default: - step: # The outcome of this step will be ignored name: 'Run linting' on-fail: strategy: ignore script: - npm install - npm run lint - step: # This step will always be executed regardless the outcome of the previous stepl. name: 'Run tests' script: - npm install - npm run test

例 — on-fail を使用して並行ステップ内のステップの失敗を無視する

pipelines: default: - parallel: # The outcome of this parallel step will be determined only by the second step. steps: - step: name: 'Run linting' on-fail: strategy: ignore script: - npm install - npm run lint - step: name: 'Run tests' script: - npm install - npm run test

例 — on-fail を使用して並行グループ内のすべての失敗を再試行する

pipelines: default: - parallel: on-fail: strategy: retry maxRetryCount: 3 steps: - step: name: 'Run test set 1' on-fail: strategy: ignore script: - npm install - npm run test set1 - step: # This step will retry up to 10 times until it passes name: 'Run test set 2' on-fail: strategy: retry maxRetryCount: 10 # This will override the value from the parent parallel group. script: - npm install - npm run test set2

例 — on-fail を使用してステージ内のすべての失敗を再試行する

pipelines: default: - stage: name: "flaky stage" on-fail: strategy: retry maxRetryCount: 3 steps: - step: # This step will retry up to 3 times until it passes name: 'Run test set' script: - npm install - npm run test

出力変数

ステップの output-variables オプションを使用して、ステップから共有パイプライン変数にエクスポートできる変数のリストを定義します。

For information on using shared pipeline variables, see the Variables and Secrets help doc.

プロパティoutput-variables

必須 — いいえ

Data type — A list of Strings (YAML spec - Sequence)

指定可能な値 — 有効な変数名

  • 名前には ASCII 文字、数字、およびアンダースコアのみを含めることができます。

  • 名前の先頭を数字にすることはできません。

Allowed parent propertiesstep

例 — output-variables オプションを使用してエクスポート可能な変数を定義する

step: script: - echo "VARIABLE_NAME=my-value" >> $BITBUCKET_PIPELINES_VARIABLES_PATH output-variables: - VARIABLE_NAME

 

同時実行グループ

concurrency-group をステップに追加すると、Bitbucket Pipelines 内の同時実行ステップのグループを定義できます。concurrency-group を指定すると、同じグループに属するステップの実行を制御して、そのグループ内のステップを一度に 1 つだけ実行することができます。これにより、リソースの使用状況を管理し、パイプライン実行での競合を回避できます。

ステップは、ステップの実行が開始された順序に基づいて、先入れ先出し (FIFO) 戦略を使用して待機します。

プロパティconcurrency-group

必須 — いいえ

データ タイプ — 文字列

指定可能な値 — 同時実行グループの名前

Allowed parent propertiesstep

設定例

pipelines: default: - step: name: Build concurrency-group: build-group script: - echo "Building the application"

 

キャッシュとアーティファクト

キャッシュ

The step caches option is used to indicate steps where dependencies are downloaded from external sources (such as package repositories like npm, and PyPI). This allows the previously defined cache to be created, updated, or reused to avoid re-downloading external build dependencies. You can use a defined custom cache, or use one of the predefined caches. For a complete list of predefined caches, see Caches — Predefined caches.

For information on using the caches option, see Caches.

プロパティcaches

必須 — いいえ

Data type — A list of Strings (YAML spec - Sequence)

Allowed values — Names of the Pre-defined Pipelines caches and the names of custom caches.

Allowed parent propertiesstep

例 — caches オプションを使用して、Ruby プロジェクトの依存関係をキャッシュする

definitions: caches: my-bundler-cache: vendor/bundle pipelines: default: - step: caches: - my-bundler-cache # Cache is defined above in the definitions section - node # Pre-defined Pipelines cache script: - bundle install --path vendor/bundle - ruby -e 'print "Hello, World\n"'

アーティファクト

The artifacts option is used to list the files or directories that contain build artifacts that are required for steps later in the pipeline. The artifact paths are relative to the BITBUCKET_CLONE_DIR variable and can be defined using glob patterns.

For details on artifacts, see using artifacts in steps.

プロパティartifacts

必須 — いいえ

データ タイプ — 次のいずれか:

Allowed parent propertiesstep

Allowed child propertiesdownload and paths

例 — artifacts を使用して、構築済みコードを次のステップに渡してテストする

pipelines: default: - step: name: Build and test script: - npm install - npm run build artifacts: - dist/** - step: name: Test code from build step stored in the dist/ directory script: - npm test

例 — artifacts、download、paths を使用して、後のステップにアーティファクトを渡す

pipelines: default: - step: name: Build and test script: - npm install - npm run build artifacts: # Store build artifacts for use in the following steps - dist/** - step: name: lint code and store results script: - npm lint > results.txt artifacts: download: false # Block artifacts downloading, they're not needed for this step paths: # Store the linting result (in addition to the dist/ directory) - results.txt - step: name: Test code from build step stored in the dist/ directory script: - npm test

アーティファクトのダウンロード

アーティファクトの download オプションは、step の開始時に前のステップからのアーティファクトをダウンロードするかどうかを制御するために使用されます。

  • download: true — (既定の動作) ステップの開始時に前のステップからのアーティファクトが開始され、stepscripts で使用できるようになります。

  • download: false — 前のステップからのアーティファクトは、この step では使用できなくなります。

For details on using artifacts, see using artifacts in steps.

プロパティdownload

必須 — いいえ

データ タイプ — ブール値

指定可能な値true または false

既定値True

Allowed parent propertiesartifacts

例 — download オプションを使用して、ステップでアーティファクトがダウンロードされないようにする
pipelines: default: - step: name: Build and test script: - npm install - npm run build artifacts: # Store build artifacts for use in the following steps - dist/** - step: name: lint code and store results script: - npm lint > results.txt artifacts: download: false # Block artifacts downloading, they're not needed for this step - step: name: Test code from build step stored in the dist/ directory script: - npm test
例 — アーティファクトの download および paths オプションを併用する
pipelines: default: - step: name: Build and test script: - npm install - npm run build artifacts: # Store build artifacts for use in the following steps - dist/** - step: name: lint code and store results script: - npm lint > results.txt artifacts: download: false # Block artifacts downloading, they're not needed for this step paths: # Store the linting result (in addition to the dist/ directory) - results.txt - step: name: Test code from build step stored in the dist/ directory script: - npm test

アーティファクトのパス

The artifact paths option is used to list the files or directories that contain build artifacts that are required for steps later in the pipeline. The paths option is only needed if the artifacts download option is defined, otherwise these paths can be listed under the artifacts option. The artifact paths are relative to the BITBUCKET_CLONE_DIR variable and can be defined using glob patterns.

For details on artifacts, see using artifacts in steps.

プロパティpaths

必須 — いいえ

Data type — A list of file paths (glob patterns are allowed) (YAML spec - Sequence)

Allowed parent propertiesartifacts

例 — アーティファクトの paths オプションを使用して、後のステップで使用するファイルを保持する
pipelines: default: - step: name: Build and test script: - npm install - npm run build artifacts: # Store build artifacts for use in the following steps - dist/** - step: name: lint code and store results script: - npm lint > results.txt artifacts: download: false # Block artifacts downloading, they're not needed for this step paths: # Store the linting result (in addition to the dist/ directory) - results.txt - step: name: Test code from build step stored in the dist/ directory script: - npm test

パイプ

pipe

Pipes make complex tasks easier, by doing a lot of the work behind the scenes. This means you can just select which pipe you want to use, and supply the necessary variables. You can look at the repository for the pipe to see what commands it is running.

For information on Pipes, including how to create and use custom Pipes, see Use pipes in Bitbucket Pipelines.

For a list of available Pipes and instructions on how to use them, see Bitbucket Pipes Integrations.

プロパティpipe

必須 — いいえ

データ タイプ — 文字列

指定可能な値 — Docker ベースのパイプのアドレス。

Allowed parent propertiesscript and after-script

Allowed child propertiesvariables (required for most pipes)

例 — pipe オプションとともに、公式の Opsgenie パイプを使用して Opsgenie アラートを送信する

pipelines: default: - step: name: Alert Opsgenie script: - pipe: atlassian/opsgenie-send-alert:latest variables: GENIE_KEY: $GENIE_KEY MESSAGE: "Danger, Will Robinson!" DESCRIPTION: "An Opsgenie alert sent from Bitbucket Pipelines" SOURCE: "Bitbucket Pipelines" PRIORITY: "P1"

例 — pipe を使用して、Opsgenie と Slack にメッセージを送信する

pipelines: default: - step: name: Alert everyone! script: - pipe: atlassian/opsgenie-send-alert:latest variables: GENIE_KEY: $GENIE_KEY MESSAGE: 'Wake up!' - pipe: atlassian/slack-notify:latest name: Send alert to Slack variables: WEBHOOK_URL: $SLACK_WEBHOOK PRETEXT: 'Alert Everyone!' MESSAGE: 'We have a problem!'

例 — pipe オプションを使用して、カスタム パイプを実行する

pipelines: default: - step: name: Running my custom pipe script: - pipe: docker://<DockerAccountName>/<ImageName>:<version> variables: USERNAME: $My_username PASSWORD: $Password

パイプ変数

パイプの variables オプションは、パイプの環境変数を設定するために使用されます。必須または使用可能な変数は、パイプによって異なります。

For information on Pipes, including how to create and use custom Pipes, see Use pipes in Bitbucket Pipelines.

For a list of available Pipes and instructions on how to use them, see Bitbucket Pipes Integrations.

Secrets and login credentials should be stored as user-defined pipeline variables to avoid being leaked. For details, see Variables and secrets — User-defined variables.

プロパティvariables

必須 — パイプによって異なります

Data type — Block of new-line separated key-value pairs (YAML spec - Block Mapping)

Allowed parent propertiespipe

例 — variables を使用して、2 つのパイプを設定して実行する

The following example shows the Opsgenie Send Alert pipe and the Slack Notify pipe.

pipelines: default: - step: name: Alert everyone! script: - pipe: atlassian/opsgenie-send-alert:latest name: Send alert to Opsgenie variables: GENIE_KEY: $GENIE_KEY MESSAGE: 'Wake up!' - pipe: atlassian/slack-notify:latest name: Send alert to Slack variables: WEBHOOK_URL: $SLACK_WEBHOOK PRETEXT: 'Alert Everyone!' MESSAGE: 'We have a problem!'

ランナー

runs-on

Only available for self-hosted pipeline runners.

自社ホスト ランナーでパイプライン ステップを実行するには、runs-on オプションをステップに追加します。パイプラインを実行すると、ステップは、リストされたすべてのラベルを含む、次に使用可能なランナーで実行されます。一致するすべてのランナーがビジー状態の場合、1 つのランナーが再び使用可能になるまでステップは待機します。リポジトリ内にすべてのラベルに一致するオンライン ランナーがない場合、ステップは失敗します。

関連情報

プロパティruns-on

必須 — いいえ

データ タイプ — 次のいずれか:

指定可能な値 — 自社ホストのリポジトリまたはワークスペース パイプライン ランナーに割り当てられた任意のラベル (self.hosted など)。

Allowed parent propertiesstep

例 — runs-on オプションを使用して、自社ホストランナーでステップを実行する

pipelines: default: - step: name: Step 1 runs-on: - 'self.hosted' - 'my.custom.label' script: - echo "This step will run on a self-hosted runner with the 'my.custom.label' and 'self.hosted' labels."; - step: name: Step 2 script: - echo "This step will run on Atlassian's infrastructure as usual.";

docker images

For details on the image options, including using the image options for steps, see Docker image options.

Git clone オプション

For details on the clone options, including using the clone options for steps, see Git clone behavior.

フロー制御

条件

condition オプションは、条件またはルールが満たされた場合を除き、stepstage が実行されないようにします。Bitbucket Pipelines は changesetsstate の 2 つの条件タイプをサポートしています。両方が指定されている場合、ステップまたはステージを実行するには両方の条件を満たす必要があります。changesets が最初に評価され、次に state が評価されます。

条件 changesets

次のいずれかに該当する場合、changesets を使用して step または stage を実行します。

  • 変更されたファイルのいずれかが includePaths の式と一致する。

  • 変更されたファイルのいくつかが excludePaths の式と一致しない。

The file match pattern specified in the includePaths and excludePaths is relative to the $BITBUCKET_CLONE_DIR directory.

考慮される変更内容

In a pull-requests pipeline, all commits are taken into account, and if you provide an list of patterns to includePaths or excludePaths, the step or stage will be executed when at least one commit change matches one of the conditions. The format for pattern matching follows the glob patterns.

その他のタイプのパイプラインでは最後のコミットのみが考慮されます。複数のコミットを同時にブランチにプッシュしたり、特定のブランチに複数回プッシュしたりすると、失敗している step または stage は次の実行でスキップされるため、失敗しているパイプラインのみが緑色に変わり、感覚的に不自然な動作が生じることがあります。

条件 state

state 条件を使用すると、ブール式が true と評価されたときのみ step または stage が実行されます。

条件が評価されるタイミングを理解する

  • 自動トリガー ステップの場合: ステップの開始準備が完了したとき、つまり前のステップが終了したときに条件が評価されます。

  • 手動トリガー ステップの場合:

    • 唯一の条件が changesets の場合、ステップを開始する準備ができたときに評価されます。

    • 条件に state 条件が含まれる場合、ユーザーが Run ボタンまたは Deploy ボタンを選択したときに評価されます。

特別なケース:

  • 再試行戦略を使用したステップ: ステップが再試行されるたびに条件が再評価されます。

  • ステップは開始されましたが停止しました: ステップが停止から再開されたときに再評価は行われません。

プロパティcondition

必須 — いいえ

Data type — Block of new-line separated key-value pairs (YAML spec - Block Mapping)

Allowed parent propertiesstep and stage

Allowed child propertieschangesets or state (required)

例 — condition オプションを使用して、特定のファイルの変更時のみにステップを実行する

pipelines: default: - step: name: step1 script: - echo "failing paths" - exit 1 condition: changesets: includePaths: # only xml files directly under path1 directory - "path1/*.xml" # any changes in deeply nested directories under path2 - "path2/**"

例 — condition オプションを使用して、特定のファイルの変更時のみにステージを実行する

pipelines: default: - stage: name: Build and test condition: changesets: includePaths: # only xml files directly under path1 directory - "path1/*.xml" # any changes in deeply nested directories under path2 - "path2/**" steps: - step: name: Build app script: - sh ./build-app.sh - step: name: Run unit tests script: - sh ./run-tests.sh

例 — 条件オプションを使用して、ブール式が true と評価された場合にのみステップを実行する

変数 prod_deployment_enabled は、環境、ワークスペース、リポジトリ、パイプライン変数で定義できます。

pipelines: default: - step: name: Deployment script: - echo "only deploy if variable prod_deployment_enabled is true" condition: state: prod_deployment_enabled == true

例 — 条件オプションを使用して、ブール式が true と評価された場合にのみステージを実行する

変数 prod_deployment_enabled は、環境、ワークスペース、リポジトリ、パイプライン変数で定義できます。

pipelines: default: - stage: name: Production Deployment condition: state: true steps: - step: name: Deployment script: - echo "only deploy if variable prod_deployment_enabled is true"

 

条件チェンジセット

条件チェンジセット

changesets オプションは、step または stagecondition が特定の 1 つ以上のファイルでの変更であることを示すために使用されます。

プロパティchangesets

Required — Required when using the condition option.

Data type — Block of new-line separated key-value pairs (YAML spec - Block Mapping)

Allowed parent propertiescondition

Allowed child properties — either includePaths or excludePaths (required)

例 — condition オプションを使用して、特定のファイルの変更時のみにステップを実行する

pipelines: default: - step: name: step1 script: - echo "failing paths" - exit 1 condition: changesets: includePaths: # only xml files directly under path1 directory - "path1/*.xml" # any changes in deeply nested directories under path2 - "path2/**"
例 — condition オプションを使用して、特定のファイルの変更時のみにステージを実行する

pipelines: default: - stage: name: Build and test condition: changesets: includePaths: # only xml files directly under path1 directory - "path1/*.xml" # any changes in deeply nested directories under path2 - "path2/**" steps: - step: name: Build app script: - sh ./build-app.sh - step: name: Run unit tests script: - sh ./run-tests.sh
条件付きチェンジセットを含むディレクトリ

condition および changesets オプションと一緒に使用すると、includePaths オプションによって、変更を確認するためのファイルまたはディレクトリのリストを提供できます。リスト内のファイルがコミットによって変更されている場合は step または stage が実行され、それ以外の場合はステップがスキップされます。

プロパティincludePaths

必須 — いいえ

Data type — A list of file paths (glob patterns are allowed) (YAML spec - Sequence)

Allowed parent propertieschangesets

例 — condition オプションを使用して、特定のファイルの変更時のみにステップを実行する
pipelines: default: - step: name: step1 script: - echo "failing paths" - exit 1 condition: changesets: includePaths: # only xml files directly under path1 directory - "path1/*.xml" # any changes in deeply nested directories under path2 - "path2/**"
例 — condition オプションを使用して、特定のファイルの変更時のみにステージを実行する
pipelines: default: - stage: name: Build and test condition: changesets: includePaths: # only xml files directly under path1 directory - "path1/*.xml" # any changes in deeply nested directories under path2 - "path2/**" steps: - step: name: Build app script: - sh ./build-app.sh - step: name: Run unit tests script: - sh ./run-tests.sh
条件付きチェンジセットの除外ディレクトリ

condition および changesets オプションと一緒に使用すると、excludePaths オプションによって、変更を確認するためのファイルまたはディレクトリのリストを提供できます。コミットによって変更されているすべてのファイルがリストに含まれている場合は step または stage がスキップされ、それ以外の場合はステップが実行されます。

プロパティexcludePaths

必須 — いいえ

Data type — A list of file paths (glob patterns are allowed) (YAML spec - Sequence)

Allowed parent propertieschangesets

例 — condition オプションを使用して、特定のファイルの変更時にステップをスキップする

pipelines: default: - step: name: step1 script: - echo "failing paths" - exit 1 condition: changesets: excludePaths: # only xml files directly under path1 directory - "path1/*.xml" # any changes in deeply nested directories under path2 - "path2/**"
例 — condition オプションを使用して、特定のファイルの変更時にステージをスキップする

pipelines: default: - stage: name: Build and test condition: changesets: excludePaths: # only xml files directly under path1 directory - "path1/*.xml" # any changes in deeply nested directories under path2 - "path2/**" steps: - step: name: Build app script: - sh ./build-app.sh - step: name: Run unit tests script: - sh ./run-tests.sh

条件のステート

条件 state

state オプションは、step または stagecondition がブール式であり、実行するには true と評価する必要があることを示すために使用されます。

プロパティstate

Required — Required when using the condition option without specifying changesets condition

データ タイプ — 文字列

Allowed parent propertiescondition

指定可能な子プロパティなし

  • (var_1 > 100 && var_1 <= 200) || var_2 == "ok" && var_3 == true

Expression languagespecifications

コンテキスト変数

  • サポートされているソース: 環境、ワークスペース、リポジトリ、パイプライン変数

  • 保護された変数とボールト変数はサポートされていません。

  • リテラルと比較する場合の変数の動的タイプ推論:

    • var_1 == true var_1 はブール値 (真/偽) でなければなりません

    • var_2 > 100 var_2 は数値でなければなりません

    • var_3 == "hello world" var_3 は任意の文字列にすることができます

変数は既定で文字列として扱われます (ブール値または数値でない限り)。そのため、コンテキスト変数に文字列を割り当てるときは、二重引用符を追加しないでください。次に例を示します。

  • 変数値が hello の場合、

    • 条件 var_3 == "hello"true として評価されます

  • 変数値が "hello" の場合 (二重引用符が明示的に使用されます)

    • 条件 var_3 == "hello"false として評価されます

    • 条件 var_3 == "\"hello\""true として評価されます

制限

  • 式の最大長: 1000 文字

changesets と組み合わせた場合の評価順序

  • changesetsstate の両方が存在する場合、ステップを実行するには両方が true でなければなりません

  • changesets が最初に評価されます。false の場合、state は評価されません

例 — ステート条件を使用して、変数が true の場合にのみステップを実行する
pipelines: default: - step: name: Plan Step script: - echo "has_change=true" >> $BITBUCKET_PIPELINES_VARIABLES_PATH output-variables: - has_change - step: name: Deployment Step condition: state: has_change == true script: - echo "deploying..."
例 — ステート条件を使用して、リポジトリ変数が true の場合にのみステージ内のステップを実行する
pipelines: default: - stage: name: Deployment condition: state: repo_var_deployment_enabled == true steps: - step: name: Build app script: - sh ./build-app.sh - step: name: Deploy app script: - sh ./deploy.sh

トリガー

Sets the stage to run automatically (default behavior) or only when manually triggered by a user in the Bitbucket user interface. The first stage in a pipeline can't be manual. To set a whole pipeline to run manually, use a custom pipeline trigger. Manual steps and stages:

  • 最初の step または stage にはできません。

  • 設定されている順序でのみ実行できます。手動の step または stage はスキップできません。

  • 前の step または stage が正常に完了した場合のみ実行できます。

  • リポジトリへの書き込みアクセス権限を持つユーザーのみがトリガーできます。

  • Pipelines の Web インターフェイス経由でトリガーされます。

If your build uses both manual steps and artifacts, the artifacts are stored for 14 days following the execution of the step that produced them. After this time, the artifacts expire and any manual steps and manual stages in the pipeline can no longer be executed.

プロパティtrigger

必須 — いいえ

データ タイプ — 文字列

指定可能な値automatic および manual

既定値automatic

Allowed parent propertiesstep and stage

例 — trigger を使用して、ステップを手動に設定する

pipelines: default: - step: name: Build script: - npm run build artifacts: - dist/** - step: name: Deploy trigger: manual script: - ./deploy.sh

例 — trigger を使用してステージを手動に設定する

pipelines: default: - stage: name: Linting steps: - step: script: - sh ./run-linter.sh - stage: name: Build and test trigger: manual steps: - step: name: Build app script: - sh ./build-app.sh - step: name: Run unit tests script: - sh ./run-tests.sh

サービス — サービス コンテナーと OIDC リソース

OpenID Connect (OIDC) リソース

The oidc option enables the use of OpenID Connect to connect a pipeline step to a resource server. The oidc value must be set to true to set up and configure OpenID Connect. For details on using OIDC with pipelines, see Integrate Pipelines with resource servers using OIDC.

プロパティoidc

必須 — いいえ

データ タイプ — ブール値

指定可能な値true または false

既定値false

Allowed parent propertiesstep

例 — oidc オプションを使用して、パイプライン ステップをリソース サーバーに接続する

pipelines: default: - step: oidc: true script: - echo "I can access data through OpenID Connect!" - aws sts assume-role-with-web-identity --role-arn arn:aws:iam::XXXXXX:role/projectx-build --role-session-name build-session --web-identity-token "$BITBUCKET_STEP_OIDC_TOKEN" --duration-seconds 1000

サービス

Bitbucket Pipelines can create separate Docker containers for services, which results in faster builds, and easy service editing. For details on creating services see Databases and service containers. This services option is used to indicate which steps require previously defined services.

プロパティservices

必須 — いいえ

Data type — A list of Strings (YAML spec - Sequence)

Allowed values — Names of services defined under definitions > services

Allowed parent propertiesstep

例 — ステップの services オプションを使用して、どのステップが my-service-name データベース サービスを必要としているかを示す

definitions: services: my-service-name: image: mariadb:latest variables: MARIADB_USER: $MY_MARIADB_USER MARIADB_PASSWORD: $MY_MARIADB_PASSWORD MARIADB_ROOT_PASSWORD: $MARIADB_ADMIN_PASSWORD pipelines: default: - step: name: Hello world example services: - my-service-name script: - echo "Hello, World"

デプロイメント

デプロイメント

Deployment の stage または step の環境を設定し、Deployment ダッシュボードを整理するために使用されます。Deployment ステージに属するすべてのステップが Deployment ステップになります。既定の環境: teststaging、または productionstep または stage のデプロイ環境を設定するには、環境名を含めます。

詳細情報

プロパティdeployment

必須 — いいえ

データ タイプ — 文字列

Allowed values — The name of a Deployment environment

Allowed parent propertiesstep and stage

例 — deployment を使用して、ステップのデプロイ環境を設定する

pipelines: default: - step: name: Deploy to production deployment: production env 1 script: - python deploy.py prod_env_1

例 — deployment を使用して、ステージのデプロイ環境を設定する

pipelines: default: - stage: name: Build and test deployment: staging steps: - step: name: Build app script: - sh ./build-app.sh - step: name: Run unit tests script: - sh ./run-tests.sh - stage: name: Deploy to Production deployment: prod trigger: manual steps: - step: name: Build app script: - sh ./build-app.sh - step: name: Run unit tests script: - sh ./run-tests.sh

環境

ステップまたはステージの環境を設定します。これにより、ブランチと管理者の権限のチェックに合格すれば、その環境を使用するステップが環境変数にアクセスできるようになります。

ステージで指定すると、そのステージ内のすべてのステップに同じ環境が割り当てられます。

step または stage の環境を設定するには、環境名を含めます。

詳細情報

プロパティenvironment

必須 — いいえ

データ タイプ — 文字列

Allowed values — The name of an Environment

Allowed parent propertiesstep and stage

例 — environment を使用してステップの環境を設定する

pipelines: default: - step: name: Deploy to production environment: production env 1 script: - python deploy.py prod_env_1

例 — environment を使用してステージの環境を設定する

pipelines: default: - stage: name: Build and test for staging environment: staging steps: - step: name: Build app script: - sh ./build-app.sh - step: name: Run unit tests script: - sh ./run-tests.sh - stage: name: Build and test for production environment: prod steps: - step: name: Build app script: - sh ./build-app.sh - step: name: Run unit tests script: - sh ./run-tests.sh

さらにヘルプが必要ですか?

アトラシアン コミュニティをご利用ください。