azure-devopsazure-pipelinespipelineazure-triggers

Azure devops pipeline: scheduled triggers not working at all


I am struggling to get scheduled triggers to work - when you check the Scheduled Triggers in the dropdown when opening the pipeline, it show no schedules, even if you press Sync to read it from the yaml file. The main pipeline yaml has the schedules, and it uses a template in 6 stages with parameters being passed to run whatever was configured, with conditions evaluating which schedule name has triggered. Unfortunately, no scheduled runs. Any ideas?

main yaml file:

trigger: none
pr: none

schedules:
- cron: '0 0 * * Tue-Sat'
  displayName: VM shutdown
  branches:
    include:
    - /deployment/compute/*
    - /main/compute/*
  always: true
- cron: '30 7 * * Mon-Fri'
  displayName: VM startup
  branches:
    include:
    - /deployment/compute/*
    - /main/compute/*
  always: true
...
stages:
- template: ../../pipelines/modules/<whatever>.yml
  parameters:
    stageCondition: 'BPC shutdown'
    stageName: 'statusVM'
    stageDisplayName: 'Status VM'
    stageDependsOn: '<previous stage name'
...

**template yaml file:**

stages:
  - stage: ${{ parameters.stageName }}
    condition: eq(variables['Build.CronSchedule.DisplayName'], '${{ parameters.stageCondition }}')
    displayName: '${{ parameters.stageDisplayName }}'
    dependsOn: '${{ parameters.stageDependsOn }}'
    jobs:
....

Coded the cron schedules, pushed to main branch and expected to see Scheduled Triggers, but none showed, thus it does not kick off at all unless manually run.


Solution

  • I have tested the YAML sample and I can reproduce the same issue.

    From the YAML Schedule trigger settings, the schedule trigger will execute every week and the always keyword value is true. It will force a pipeline to run even when there are no code changes, and it will show the Trigger Run list.

    The cause of the issue could be that the YAML file(contains schedule trigger) doesn't exists in all branches that needs to be used in the schedule trigger.

    To solve this issue, you need to copy the main yaml file to all branches that needs to be used in the schedule trigger(e.g. deployment/compute/* ,main/compute/* ).

    Note: You need to keep the yaml file with the SAME file name in all branches.

    For example:

    Branch1:

    enter image description here

    Branch2:

    enter image description here

    Result:

    enter image description here