スケジュールされたトリガーは、ブランチを構築するスケジュールを指定します。
schedules:
- cron: string # Required as first property. Cron syntax defining a schedule in UTC time.
displayName: string # Optional friendly name given to a specific schedule.
branches: # Branch names to include or exclude for triggering a run.
include: [ string ] # List of items to include.
exclude: [ string ] # List of items to exclude.
batch: boolean # Whether to run the pipeline if the previously scheduled run is in-progress; the default is false.
always: boolean # Whether to always run the pipeline or only if there have been source code or pipeline settings changes since the last successful scheduled run. The default is false.
schedules:
- cron: string # Required as first property. Cron syntax defining a schedule in UTC time.
displayName: string # Optional friendly name given to a specific schedule.
branches: # Branch names to include or exclude for triggering a run.
include: [ string ] # List of items to include.
exclude: [ string ] # List of items to exclude.
always: boolean # Whether to always run the pipeline or only if there have been source code or pipeline settings changes since the last successful scheduled run. The default is false.
特性
cron
文字列。 最初のプロパティとして必要です。
スケジュールを UTC 時刻で定義する Cron 構文を します。
displayName
文字列。
特定のスケジュールに指定された省略可能なフレンドリ名です。
includeExcludeFiltersを
実行をトリガーするために含めるか除外するブランチ名。
ブールを batch
します。
batch
プロパティは、以前にスケジュールされた実行が進行中の場合にパイプラインを実行するかどうかを構成します。
batch
が true
場合、以前のパイプラインの実行がまだ進行中の場合、スケジュールにより新しいパイプラインの実行は開始されません。 既定値は false
です。
batch
プロパティは、always
プロパティの設定の影響を受けます。
always
が true
されると、batch
が true
され、進行中の実行がある場合でも、cron スケジュールに従ってパイプラインが実行されます。
いつも | バッチ | 行動 |
---|---|---|
false |
false |
パイプラインの実行は、最後に成功したスケジュールされたパイプラインの実行に関する変更がある場合にのみ実行されます。 |
false |
true |
パイプラインの実行は、最後に成功したスケジュールされたパイプラインの実行に関して変更があり、進行中のスケジュールされたパイプラインの実行がない場合にのみ実行されます。 |
true |
false |
パイプラインは、cron スケジュールに従って実行されます。 |
true |
true |
進行中の実行がある場合でも、cron スケジュールに従ってパイプラインが実行されます。 |
ブールを always
します。
パイプラインを常に実行するか、前回成功したスケジュールされた実行以降にソース コードが変更された場合にのみ実行するかを指定します。既定値は false です。
注釈
スケジュールされたトリガーを指定しない場合、スケジュールされたビルドは発生しません。
注
exclude
に include
句を指定せずに branches
句を指定する場合、*
句で include
を指定することと同じです。
重要
パイプライン設定 UI を使用して定義されたスケジュールされたトリガーは、YAML のスケジュールされたトリガーよりも優先されます。
YAML パイプラインに YAML スケジュールされたトリガーと UI で定義されたスケジュールされたトリガーの両方がある場合、UI で定義されたスケジュールされたトリガーのみが実行されます。 YAML パイプラインで YAML 定義のスケジュールされたトリガーを実行するには、パイプライン設定 UI で定義されているスケジュールされたトリガーを削除する必要があります。 すべての UI スケジュールされたトリガーが削除されたら、YAML スケジュールされたトリガーの評価を開始するためにプッシュを行う必要があります。
YAML パイプラインから UI スケジュールされたトリガーを削除するには、UI 設定 YAML スケジュールされたトリガーオーバーライドする方法に関する記事を参照してください。
Build.CronSchedule.DisplayName 変数
cron スケジュールされたトリガーが原因でパイプラインが実行されている場合、定義済みの Build.CronSchedule.DisplayName
変数には、パイプラインの実行をトリガーした cron スケジュールの displayName
が含まれます。
YAML パイプラインには複数の cron スケジュールが含まれている場合があり、どの cron スケジュールを実行するかに基づいて、パイプラインで異なるステージまたはジョブを実行できます。 たとえば、夜間ビルドと毎週のビルドがあり、夜間ビルド中にのみ特定のステージを実行する必要があるとします。 ジョブまたはステージ条件で Build.CronSchedule.DisplayName
変数を使用して、そのジョブまたはステージを実行するかどうかを決定できます。
- stage: stage1
# Run this stage only when the pipeline is triggered by the
# "Daily midnight build" cron schedule
condition: eq(variables['Build.CronSchedule.DisplayName'], 'Daily midnight build')
その他の例については、次の 例 セクションを参照してください。
例示
次の例では、2 つのスケジュールを定義します。
最初のスケジュール 毎日午前 0 時のビルドは、スケジュールされた最後の実行が成功した後にコードが変更された場合にのみ、毎日午前 0 時にパイプラインを実行します。
main
の下にあるブランチを除き、releases/*
とすべての releases/ancient/*
ブランチのパイプラインを実行します。
2 番目のスケジュール 毎週日曜日のビルドは、すべての releases/*
ブランチに対して日曜日の正午にパイプラインを実行します。
これは、前回の実行以降にコードが変更されたかどうかに関係なく行われます。
schedules:
- cron: '0 0 * * *'
displayName: Daily midnight build
branches:
include:
- main
- releases/*
exclude:
- releases/ancient/*
- cron: '0 12 * * 0'
displayName: Weekly Sunday build
branches:
include:
- releases/*
always: true
スケジュールされたトリガーによってスケジュールされたかどうかに基づいてステージまたはジョブを条件付きで実行するには、条件で Build.CronSchedule.DisplayName
変数を使用します。 この例では、stage1
Daily midnight build
スケジュールによってパイプラインがトリガーされた場合にのみ実行され、job3
Weekly Sunday build
スケジュールによってパイプラインがトリガーされた場合にのみ実行されます。
stages:
- stage: stage1
# Run this stage only when the pipeline is triggered by the
# "Daily midnight build" cron schedule
condition: eq(variables['Build.CronSchedule.DisplayName'], 'Daily midnight build')
jobs:
- job: job1
steps:
- script: echo Hello from Stage 1 Job 1
- stage: stage2
dependsOn: [] # Indicate this stage does not depend on the previous stage
jobs:
- job: job2
steps:
- script: echo Hello from Stage 2 Job 2
- job: job3
# Run this job only when the pipeline is triggered by the
# "Weekly Sunday build" cron schedule
condition: eq(variables['Build.CronSchedule.DisplayName'], 'Weekly Sunday build')
steps:
- script: echo Hello from Stage 2 Job 3
こちらもご覧ください
- スケジュールされたトリガー 詳細を確認します。
- 一般的な トリガー とその指定方法について説明します。