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
スケジュールされたパイプラインと、手動でトリガーされたパイプライン
Bitbucket を使用すると、複数のパイプラインを手動でトリガーするか、特定の時間にトリガーをスケジュールすることで、複数のパイプラインを実行できます。
概要
パイプライン ステップを手動で実行する
手動ステップにより、手動でトリガーされたときにのみ実行されるステップを構成して、CI/CD パイプラインをカスタマイズできます。これは、ステップの実行前に手動でのテストやチェックが必要になる、デプロイ ステップなどの項目で便利です。
手動ステップを定義するには、bitbucket-pipelines.yml ファイルのステップに trigger: manual を追加します。
Since a pipeline is triggered on a commit, you can't make the first step manual. If you'd like a pipeline to only run manually, you can set up a custom pipeline instead. Another advantage of a custom pipeline is that you can temporarily add or update values for your variables, for example, to add a version number, or supply a single-use value.
手動パイプラインを設定する
Any existing pipeline can also be manually run against a specific commit, or as a scheduled build.
パイプラインを手動でのみ実行したい場合は、カスタム パイプラインを使用します。カスタム パイプラインは、ブランチへのコミットでは自動的に実行されません。カスタム パイプラインを定義するには、bitbucket-pipelines.yml ファイルの custom セクションにパイプライン構成を追加します。カスタム パイプラインとして定義されていないパイプラインは、ブランチへのプッシュが発生したときに自動的に実行されます。
パイプラインを手動で実行し、Bitbucket Cloud UI からトリガーするには、リポジトリでの書き込み権限が必要です。
セットアップ
bitbucket-pipelines.ymlファイルにパイプラインを追加します。bitbucket-pipelines.ymlファイルに含まれるパイプライン ビルド構成のビルドを手動でトリガーできます。
例:pipelines: custom: # Pipelines that can only be triggered manually sonar: - step: script: - echo "Manual triggers for Sonar are awesome!" deployment-to-prod: - step: script: - echo "Manual triggers for deployments are awesome!" branches: # Pipelines that run automatically on a commit to a branch can also be triggered manually staging: - step: script: - echo "Automated pipelines are cool too."Bitbucket Cloud からパイプラインをトリガーします。パイプラインは、Bitbucket Cloud のブランチ ビューまたはコミット ビューから手動でトリガーできます。
ブランチ ビューからパイプラインを手動で実行する
Bitbucket でリポジトリを選択し、[ブランチ] に移動します。
パイプラインを実行するブランチを選択します。
Select (...) , and select Run pipeline for a branch.
Choose a pipeline and select Run
コミット ビューからパイプラインを手動で実行する
Bitbucket でリポジトリを選択し、[コミット] に移動します。
コミット ビューに移動してコミットを表示します。
コミット ハッシュを選択します。
[パイプラインの実行] を選択します。
Choose a pipeline, then select Run
Pipelines ページからパイプラインを手動で実行
Bitbucket でリポジトリを選択し、[Pipelines] に移動します。
Select Run pipeline
Choose branch, a pipeline, and select Run
さらに、カスタム パイプラインを実行して、パイプラインに変数を手動でパースできます。
変数を有効化するには、パイプラインを実行するときに入力するカスタム パイプラインの下に変数を定義します。
例:
pipelines:
custom:
custom-name-and-region: #name of this pipeline
- variables: #list variable names under here
- name: Username
- name: Region
- step:
script:
- echo "User name is $Username"
- echo "and they are in $Region"[Branches] > [⋯] > [ブランチでパイプラインを実行] > [カスタム] に移動して、カスタム パイプラインを実行します。
オンスケジュール
スケジュールされたパイプラインを使用すると、パイプラインを時間、日、または週単位で実行できます。
スケジュールされたパイプラインは、コミットや手動操作でトリガーされるあらゆるビルドに追加して実行できます。
bitbucket-pipelines.ymlファイルで定義したすべてのパイプラインにスケジュールを作成できます。カスタム パイプラインを作成した場合、それはスケジュールされたときまたは手動でトリガされたときにのみ実行されます。
セットアップ
パイプラインを作成します。bitbucket-pipelines.yml ファイルでカスタム パイプラインを定義する簡単な例を示します。
例:
pipelines:
custom: # defines that this can only be triggered manually or by a schedule
staging: # The name that is displayed in the list in the Bitbucket Cloud GUI
- step:
script:
- echo "Scheduled builds in Pipelines are awesome!"Read more about custom pipelines.
パイプラインのスケジュールを作成する
Bitbucket のリポジトリに移動します。
Select Pipelines then Schedules (at the top right), and then select New schedule.
スケジュールを登録したいブランチとパイプラインを選択します。
スケジュール実行は、ブランチの HEAD コミットを実行します。
パイプラインは、選択したブランチの
bitbucket-pipelines.ymlの中で定義する必要があります。
スケジュールを設定します。
パイプラインの実行間隔を選択します (時間、日、または週単位)。
ご利用のタイムゾーンで時間を選択します。パイプラインは UTC 時刻でスケジュールされます (夏時間の影響は受けません)。
スケジュールされたパイプラインは、選択した期間内の任意のタイミングで実行されます。これは、その期間にスケジュールされたパイプラインのトリガーを分散させるためです。
スケジュールの削除
Go to Pipelines, then Schedules (at the top right-hand side of the screen) to see all the schedules for a repository.
スケジュールの右側にあるゴミ箱アイコンを使用してスケジュールを削除します。
Note that schedules created using the API are displayed as a Cron expression (such as
0 10 15 * *).
この内容はお役に立ちましたか?