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 からトリガーするには、リポジトリでの書き込み権限が必要です。

セットアップ

  1. 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."
  2. Bitbucket Cloud からパイプラインをトリガーします。パイプラインは、Bitbucket Cloud のブランチ ビューまたはコミット ビューから手動でトリガーできます。

ブランチ ビューからパイプラインを手動で実行する

  1. Bitbucket でリポジトリを選択し、[ブランチ] に移動します。

  2. パイプラインを実行するブランチを選択します。

  3. Select (...) , and select Run pipeline for a branch.

  4. Choose a pipeline and select Run

コミット ビューからパイプラインを手動で実行する

  1. Bitbucket でリポジトリを選択し、[コミット] に移動します。

  2. コミット ビューに移動してコミットを表示します。

  3. コミット ハッシュを選択します。

  4. [パイプラインの実行] を選択します。

  5. Choose a pipeline, then select Run

Pipelines ページからパイプラインを手動で実行

  1. Bitbucket でリポジトリを選択し、[Pipelines] に移動します。

  2. Select Run pipeline

  3. 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] > [] > [ブランチでパイプラインを実行] > [カスタム] に移動して、カスタム パイプラインを実行します。

var

オンスケジュール

スケジュールされたパイプラインを使用すると、パイプラインを時間、日、または週単位で実行できます。

  • スケジュールされたパイプラインは、コミットや手動操作でトリガーされるあらゆるビルドに追加して実行できます。

  • 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.

パイプラインのスケジュールを作成する

  1. Bitbucket のリポジトリに移動します。

  2. Select Pipelines then Schedules (at the top right), and then select New schedule.

  3. スケジュールを登録したいブランチパイプラインを選択します。

    • スケジュール実行は、ブランチの HEAD コミットを実行します。

    • パイプラインは、選択したブランチの bitbucket-pipelines.yml の中で定義する必要があります。  

  4. スケジュールを設定します。

    • パイプラインの実行間隔を選択します (時間、日、または週単位)。

    • ご利用のタイムゾーンで時間を選択します。パイプラインは 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 * *).

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

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