- Bitriseドキュメントへようこそ!
- ワークフローとパイプライン
- パイプライン
- Configuring Pipelines
Configuring Pipelines
ワークフローを追加し、オプションでワークフロー間の依存関係を定義して、Bitriseパイプラインを設定します。
ステージ付きパイプライン
2024年12月以前の既存のパイプライン構成がある場合は、パイプラインにステージがある可能性があります。ステージの使用をやめて、代わりにワークフロー間の依存関係の設定に集中することを強くお勧めします。これらの依存関係によって、パイプラインでの実行順序が決まります。これにより、段階的な不必要な待ち時間がなくなり、より柔軟な CI 構成を作成できます。
ステージ付きのパイプラインは引き続き使用できますが、将来的には新しい機能はありません。同じ設定 YAML ファイルに両方のタイプのパイプラインを含めることはできますが、2 つのタイプを混在させることはできません。同じパイプラインにステージとワークフロー依存関係の両方を含めることはできません
ステージ付きのパイプラインのドキュメントは、次の場所にあります。 パイプラインの構築[ベータ版].
You can define your Pipelines under a pipelines
element in a configuration YAML file. You can use the following elements to set up a Pipeline:
-
A Pipeline name: the human readable identifier of the Pipeline.
-
The
workflows
element: this contains a list of the Workflows that are part of the Pipeline. -
The
depends_on
property: This is a property of theworkflows element
and accepts an array of Workflow names. It defines the dependencies between Workflows.
For example, here's a simple Pipeline configuration:
In this Pipeline, we have four Workflows:
-
Workflow A runs first.
-
Once Workflow A is finished, Workflows B and C start at the same time.
-
Workflow D starts only when both Workflows B and C are successfully finished.
パイプラインの作成
ワークフローエディター
コンフィギュレーション YAML
ワークフローエディターを開いて選択してください パイプライン 左側にあります。 [パイプラインを作成]。
最初のワークフローを追加するには、をクリックします ワークフロー。
この方法でワークフローを追加し続けることができます。この方法では、ワークフロー間の依存関係は発生しません。すべてのワークフローが同時に実行されます。
ワークフローの依存関係を作成するには、ワークフローの右端にカーソルを合わせ、プラス記号をクリックします。
次の方法で、複数の依存ワークフローを同じワークフローに追加できます。
同じワークフローが複数の異なるワークフローに依存する場合があります。プラス記号からパイプラインにすでに存在する別のワークフローにドラッグしてパスを作成できます。
最低限のパイプライン設定は、1つのワークフローで構成されています。
pipelines: example: workflows: A: {}
複数のワークフローをすべて並行して実行できます。
pipelines: example: workflows: A: {} B: {} C: {}
To create Workflow dependencies like the example above, you need to use the depends_on
property:
pipelines: example: workflows: A: {} B: depends_on: - A C: depends_on: - A D: depends_on: - B - C
If a Workflow depends on multiple Workflows, both YAML array syntaxes can be used:
# Option 1 D: depends_on: - B - C # Option 2 D: depends_on: [A, B]
Configuration restrictions
-
A Pipeline can have a maximum of 50 Workflows. Each must be an existing Workflow under the root level
workflows
element. -
Utility Workflows can't be added to a Pipeline. If you want to use utility Workflows, include them as part of a regular Workflow.
-
Each Workflow can be added to the same Pipeline only once. You can't include the same Workflow in multiple different parts of a Pipeline.
-
Any Workflow defined in the dependency list must be part of the same Pipeline.
-
The dependency graph resulting from your configuration can't contain a circle or loop. Such an error will builds from starting.
Conditional Workflow execution in a Pipeline
Use run_if
expressions to control Workflow execution: you can set conditions under which a Workflow should or should not run.
ワークフローエディター
コンフィギュレーション YAML
-
パイプラインを開きます。
-
必要なワークフローにカーソルを合わせ、歯車アイコンをクリックして「ワークフローの編集」ダイアログを開きます。
-
[選択] パイプライン条件。
-
の中に その他の実行条件 入力、有効値の追加 テンプレートに移動。
入力は次の 3 つの補助関数を受け入れます。
-
getenv
: Accesses an Environment Variable's value. -
enveq
: Compares an Environment Variable to a given value. -
envcontain
: Checks whether an Environment Variable contains a given string.
-
-
「ワークフローを編集」ダイアログを閉じて、をクリックします。 [変更を保存]。
パイプラインでは、 run_if
プロパティには expression
を含むフィールド Go テンプレート:
pipelines: example: workflows: A: {} B: run_if: expression: {{ enveq "EXAMPLE_KEY" "example value" }} depends_on: [A]
The expression
field accepts three helper functions:
-
getenv
: Accesses an Environment Variable's value. -
enveq
: Compares an Environment Variable to a given value. -
envcontain
: Checks whether an Environment Variable contains a given string.
Bitrise CLIは実行時に式を評価します。ワークフローは次の場合のみ実行されます run_if
エクスプレッションは次のように評価されます。 true
。が原因でスキップされたワークフロー run_if
expression は成功したワークフローとしてカウントされるため、依存するワークフローが実行されます。
In this example, B will only run if the EXAMPLE_KEY
Environment Variable has the value example value
.
Always executing a Workflow in a Pipeline
You can mark a Workflow to make sure it runs even if a Workflow it depends on failed.
推移的依存
ワークフローが常に実行されるように設定されていても、その依存ワークフローは実行されない場合があります。1 つ以上の親ワークフローが失敗しても、問題のワークフローは引き続き実行されますが、依存するワークフローは実行されない可能性があります。
たとえば、ワークフロー C がワークフロー B に依存しているとします。ワークフロー B はワークフロー A に依存しています。3 つのワークフローのうち、B だけが常に実行されるように設定されています。
-
If A fails, B will run but regardless of its result, C won't run because by depending on B, it also depends on A.
-
C only runs if both A and B are successful.
ワークフローエディター
コンフィギュレーション YAML
-
パイプラインを開きます。
-
必要なワークフローにカーソルを合わせ、歯車アイコンをクリックして「ワークフローの編集」ダイアログを開きます。
-
[選択] パイプライン条件。
-
を設定 [常に実行] への入力 ワークフロー。
この設定は、1 つ以上の親ワークフローが失敗した場合でも、ワークフローが実行されることを意味します。ただし、依存するワークフローは実行されない可能性があります。
を使う should_always_run
プロパティ。設定の範囲を指定する文字列が必要です。次の 2 つの値を使用できます。
-
none
: If a parent Workflow fails, the Workflow will not run. This is the default value. -
workflow
: If a parent Workflow fails, the Workflow will run anyway.
pipelines: example: workflows: A: {} B: depends_on: [ A ] should_always_run: workflow C: depends_on: [ B ] D: depends_on: [ C ] should_always_run: workflow
In this example:
-
If A fails, B still runs.
-
If either A or B fails, C won't run.
-
If C won't run or runs but fails, D will still run.
Aborting the Pipeline on Workflow failure
You can configure the Pipeline to immediately terminate when any given Workflow fails. By default, the Pipeline won't terminate
Workflow Editor
Configuration YAML
-
パイプラインを開きます。
-
必要なワークフローにカーソルを合わせ、歯車アイコンをクリックして「ワークフローの編集」ダイアログを開きます。
-
[選択] パイプライン条件。
-
Toggle the Abort Pipeline on failure input on.
If the Workflow in question fails, the Pipeline will immediately stop running.
Add the abort_on_fail
field set to true
to the selected Workflows:
pipelines: example: workflows: A: {} B: abort_on_fail: true
In this example, the Pipeline stops running if Workflow B fails: Workflow A will be aborted and no subsequent Workflows will run.
Sharing files between Workflows in a Pipeline
To share files between Workflows in a Pipeline, you can use the Deploy to Bitrise.io Step and the Pull Pipeline intermediate files Step. The Step downloads Pipeline intermediate files to a local folder.
To configure file sharing:
Workflow Editor
Configuration YAML
-
Add the Deploy to Bitrise.io Step to the Workflow that generates the file(s) you need.
-
In the Pipeline Intermediate File Sharing input group, find the Files to share input and add the files as a newline-separated list of colon-separated items using the following structure:
<file_or_directory_path>:<environment_variable_key>
.別の環境変数をファイルパスとして使用できます。iOS プロジェクトの場合は、
$BITRISE_IPA_PATH:BITRISE_IPA_PATH
生成された IPA を他のワークフローと共有する有効な方法です。 -
を追加 パイプラインの中間ファイルをプルする 生成されたファイルを必要とする任意のワークフローに進みます。
-
を使う アーティファクトソース ファイルを必要とするワークフローのセットを指定するための入力。
入力にはワイルドカードを使用できます。上の例では、名前がで始まるすべてのワークフローからすべてのアーティファクトを抽出しています
workflow
。 -
ステップが終了すると、ファイルおよびディレクトリは Bitrise.io にデプロイ-アプリ、ログ、アーティファクト ステップが利用できるはずです。
-
Add the Deploy to Bitrise.io Step to the Workflow that generates the file(s) you need.
-
Add the files to the
pipeline_intermediate_files
input as a newline-separated list of colon-separated items using the following structure:<file_or_directory_path>:<environment_variable_key>
.You can use another Environment Variable as a filepath: for an iOS project,
$BITRISE_IPA_PATH:BITRISE_IPA_PATH
is a valid way to share a generated IPA with other Workflows.steps: - deploy-to-bitrise-io: { inputs: - pipeline_intermediate_files: "$BITRISE_IPA_PATH:BITRISE_IPA_PATH"
-
Add the Pull Pipeline intermediate files Step to any Workflow that needs the generated files:
steps: - pull-intermediate-files: {}
-
Use the
artifact_sources
input to specify a set of Workflows from which you need files:steps: - pull-intermediate-files@1: inputs: - artifact_sources: workflow.*
You can use wildcards in the input. In the example above, we’re pulling all artifacts from all Workflows which have a name starting with
workflow
. -
When the Step finishes, your files and directories specified via the Deploy to Bitrise.io - Apps, Logs, Artifacts Step should be available.
詳細については、 ステップ リポジトリ.
ワークフロー間での環境変数の共有
から任意の環境変数を再利用できます。 ワークフロー その後で再利用します ステージ を使用して パイプライン変数を共有するステップ.このステップを使用して環境変数を共有しても、 アプリ.
run_if 条件を使用したオプションのワークフロー
簡単に組み合わせることができます パイプライン変数を共有する ステップ run_if
オプションのワークフローでパイプラインを作成するための式。詳細については、こちらをご覧ください パイプラインを使用したオプションのワークフローの run_if 条件の設定.パイプラインを使用したオプションのワークフローの run_if 条件の設定
そうするために:
-
追加 パイプライン変数を共有する ワークフローに進みます。
-
必要に応じて、追加の実行条件を 追加の実行条件 入力。ステップは、ここで指定した条件が真の場合にのみ実行されます。
-
Add the Env Var(s) you would like to use in subsequent Workflows in the Variables to share between Pipeline Workflows input.
環境変数キーの使用
を使用して環境変数を定義できます。
{key}={value}
構文。例えば、MY_ENV_KEY=value
、 またINSTALL_PAGE_URL=$BITRISE_PUBLIC_PAGE_URL
.デフォルトの環境変数キーを使用する場合は、簡略構文を使用できます。例えば、
EXISTING_ENV_KEY
.このステップを使用して環境変数を共有しても、 アプリ.