Documentation structure for LLMs (llms.txt)

Schedule triggers with multiple workflows

Cloud
Schedule triggers are not currently available for GitLab and Bitbucket Data Center projects.

By default, when a pipeline is triggered via schedule trigger each of its workflows will run. You can filter workflows in your .circleci/config.yml file with conditionals. The conditionals you set will control which workflows will run when a pipeline is triggered via schedule. These conditions can be set with built-in pipeline values, or through custom pipeline parameters. The examples below demonstrate various ways to set conditionals in your .circleci/config.yml file.

Schedule using built-in pipeline values

One way to implement workflows filtering is by using pipeline values. The example below uses the built-in pipeline values pipeline.trigger_source and pipeline.schedule.name. The examples use daily_build and nightly_build as the pipeline.schedule.name. However, the value of pipeline.schedule.name can be whatever you would like when using schedule triggers.

version: 2.1
...
daily-run-workflow:
# run workflow only when the daily_build pipeline is triggered
  when: pipeline.trigger_source == "scheduled_pipeline" and pipeline.schedule.name == "daily_build"
  jobs:
    - test
    - build

nightly-run-workflow:
# run workflow only when the nightly_build pipeline is triggered
  when: pipeline.trigger_source == 'scheduled_pipeline' and pipeline.schedule.name == 'nightly_build'
  jobs:
    - build
    - deploy
...

You may also add filtering for workflows that do not run when a schedule is triggered:

version: 2.1
...
daily-run-workflow:
# run workflow only when the daily_build pipeline is triggered
  when: pipeline.trigger_source == "scheduled_pipeline" and pipeline.schedule.name == "daily_build"
  jobs:
    - test
    - build

nightly-run-workflow:
# do NOT run workflow if a schedule trigger is triggered
  when: pipeline.trigger_source != "scheduled_pipeline"
  jobs:
   - build
   - deploy
...

For a full list of pipeline values, visit the Pipeline Values and Parameters page.

Schedule using pipeline parameters

In the example below, a parameter is created called run-schedule, which is set as type: boolean and default: false. This allows the workflows section to use when to specify conditionals about when the pipeline runs. If you use the when conditional, you will also need to set a when: not:, like in the example below.

version: 2.1
...
# set pipeline parameters
parameters:
  run-schedule:
    type: boolean
    default: false

workflows:
  # do not run the schedule trigger if build-test-deploy
  build-test-deploy:
    when: pipeline.parameters.run-schedule == false
    jobs:
      - test
      - build
  # run the schedule trigger if nightly-snapshot
  nightly-snapshot:
    when: << pipeline.parameters.run-schedule >>
    jobs:
      - build
      - deploy
...

For the full configuration sample, visit the sample project on GitHub. For a full list of pipeline parameters, see the Pipeline Values and Parameters page.

Set up multiple workflows with multiple schedules

The example below demonstrates three workflows each scheduled with a different pipeline value: daily_build, nightly_build, and weekly_build:

version: 2.1
...
workflows:
# run workflow only when the daily_build pipeline is triggered
  daily-run-workflow:
    when: pipeline.schedule.name == 'daily_build'
    jobs:
      - job-one

  nightly-run-workflow:
  # run workflow only when the nightly_build pipeline is triggered
    when: pipeline.schedule.name == 'nightly_build'
    jobs:
      - job-two

  weekly-run-workflow:
  # run workflow only when the weekly_build pipeline is triggered
    when: pipeline.schedule.name == 'weekly_build'
    jobs:
      - job-three
...