schedules.cron 정의

예약된 트리거는 분기가 빌드되는 일정을 지정합니다.

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 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 changes since the last successful scheduled run; the default is false.

이 정의를 참조하는 정의: 일정

속성

cron 문자열. 첫 번째 속성으로 필요합니다.
UTC 시간으로 일정을 정의하는 Cron 구문입니다.

displayName 문자열.
특정 일정에 지정된 선택적 이름입니다.

branchesincludeExcludeFilters.
실행을 트리거하기 위해 포함하거나 제외할 분기 이름입니다.

batchboolean입니다.
이전에 예약된 실행이 진행 중인 경우 파이프라인을 실행할지 여부입니다. 기본값은 입니다 false. 파이프라인 리포지토리의 버전과 관계가 없습니다.

다음 표에서는 및 batch 상호 작용하는 방법을 always 설명합니다.

항상 Batch 동작
false false 파이프라인은 마지막으로 성공한 예약된 파이프라인 실행에 대한 변경 내용이 있는 경우에만 실행됩니다.
false true 파이프라인은 마지막으로 성공한 예약된 파이프라인 실행에 대한 변경 내용이 있고 진행 중인 예약된 파이프라인 실행이 없는 경우에만 실행됩니다.
true false 파이프라인은 cron 일정에 따라 실행됩니다.
true true 파이프라인은 cron 일정에 따라 실행됩니다.

중요

가 인 true경우 always 파이프라인은 가 인 경우에도 batchtruecron 일정에 따라 실행됩니다.

alwaysboolean입니다.
파이프라인을 항상 실행할지 또는 마지막으로 성공적으로 예약된 실행 이후 소스 코드가 변경된 경우에만 실행할지 여부입니다. 기본값은 false입니다.

설명

예약된 트리거를 지정하지 않으면 예약된 빌드가 발생하지 않습니다.

참고

에 대한 branches절 없이 절을 include 지정 exclude 하는 경우 절에서 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')

자세한 예제는 다음 예제 섹션을 참조 하세요 .

예제

다음 예제에서는 두 개의 일정을 정의합니다.

첫 번째 일정인 매일 자정 빌드는 마지막으로 성공한 예약 실행 이후 코드가 변경된 경우에만 매일 자정에 파이프라인을 실행합니다. 아래의 분기를 제외하고 및 모든 releases/* 분기에 대해 main 파이프라인을 releases/ancient/*실행합니다.

두 번째 일정인 매주 일요일 빌드는 모든 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

추가 정보