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

並行ステップ オプション

並列ステップによって、一度に (同時に) 実行できるパイプライン ステップをグループ化して、ビルド時間を短縮できます。

概要

並列ステップのセットアップまたは実行

並行ステップを使用すると、自己完結型の一連のステップを同時に実行して、ビルドやテストを迅速に行えます。 ステップを並行した場合も、パイプラインが使用する合計のビルド時間数は変わりません。結果を早く確認できるようになりますが、使用した合計ビルド時間は、各ステップでかかった合計時間に基づいて計算されます。

この機能はさまざまな方法で使用できますが、次のガイドラインに従うことをお勧めします。

  1. ソフトウェアをビルドするための最初のステップを設定します。

  2. ソフトウェアをテストするための一連の並行ステップを追加します。
    複数の並行テスト ステップにつながる 1 つのビルド ステップを実行している場合、最初のステップで、外部ビルドの依存関係を可能な限り多くキャッシュすると、それぞれのテスト ステップ実行時の時間を節約できます。その後、すべてのテストを同時に実行します。テストはキャッシュを使用できます。

  3. 複数の類似環境に同時にデプロイします。

例:

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

並行ステップの既定変数

In addition to the standard pipelines variables, parallel step groups also have the following default variables:

  • BITBUCKET_PARALLEL_STEP - グループ内の現在のステップのゼロベース インデックス (例: 0、1、2…)。

  • BITBUCKET_PARALLEL_STEP_COUNT - グループ内のステップの合計数。

並行ステップの制限

  • パイプラインにおける 100 ステップの制限には、並行グループの各ステップも含まれます。

  • 並列ステップ セット内のすべての環境は同じタイプでなければなりません。同じセットに本番環境タイプとテスト環境タイプを混在させないでください。

  • 並行ステップでは、アーティファクトを生成および消費できます。次の点に注意します。

    • 並行ステップでは、以前のステップで生成されたアーティファクトのみを使用できます。同じ並行セットのステップで生成されたものは使用できません。

    • 並行セットのあとのステップは、生成されたすべてのファイルの組み合わせを取得します。

    • ファイルを含むアーティファクトが並行ステップによって同じ場所に生成された場合、競合はファイル単位で解消され、YAML ファイルの最後のステップで生成されたファイルが優先されます。

  • 実行中のすべてのパイプラインにわたって Bitbucket ワークスペースが一度に実行できるステップ数は、プランによって異なります。

    • Standard と Premium の各ワークスペースでは、複数のパイプラインで同時に実行される 600 ステップをサポートできます。

    • 無料のワークスペースでは、複数のパイプラインで同時に実行する 10 ステップをサポートできます。

    • この制限に到達すると、超過したステップは失敗します。

並行ステップ オプション

並行ステップ グループを設定するには、次のオプションを使用できます。

parallel

parallel オプションでは、ステップのリストを同時に実行することで、コードの生成とテストを高速化できます。ステップを並行にした場合でも、パイプラインが使用するビルドの合計時間数は変わりませんが、結果はより早く表示されます。パイプライン定義に設定できるステップの合計数は、並列または単独のどちらで実行されているかにかかわらず、100 に制限されます。

For details on using parallel steps, see Set up or run parallel steps.

プロパティparallel

必須 — いいえ

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

Allowed parent propertiesdefault, branches, pull-requests, tags, and custom

Allowed child propertiessteps (required), fail-fast, and on-fail

例 — parallel オプションを使用して、2 つのステップを同時に実行する

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

手順

steps プロパティには、stage または parallelstep のリストが含まれます。ステップ リストには少なくとも 1 つの step が必要です。

プロパティsteps

必須 — はい

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

Allowed parent propertiesparallel and stage

Allowed child propertiesstep (required)

例 — step プロパティを使用して、並行グループのステップをリストする

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

例 — step プロパティを使用して、ステージのステップをリストする

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

fail-fast

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

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

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