简体   繁体   中英

Cron. Is it possible run every day except evry second Thursday and Friday?

I need to make sure that the pipeline runs every day except every second Thursday and Friday by cron. The cron is located in the azure pipeline. Now I have this:

schedules:
- cron: 0 19 * * 1-5
  displayName: evening-deployment
  branches:
    include: 
    - develop
  always: false

There is no cron onliner for this. Alternatively you could add multiple schedules, crons, in the same pipeline.

For more info see:

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/scheduled-triggers?view=azure-devops&tabs=yaml#example-nightly-build-with-different-frequencies-1

I am afraid that there is no out-of-box method can directly meet your requirements.

The definition of cron in Pipeline cannot automatically judge every second Thursday and Friday.

For workarounds, You can manually check the days of the month that you don't want the Pipeline to run and hardcode the other days in cron.

For example: you need the pipeline run from 1-7,11-21, 25-30.

schedules:
- cron: "0 19 1-7,11-21, 25-30 * 1-5" 
  displayName: schedule
  branches:
    include:
    - master
  always: true

In this case, you need to manually change the run date at the beginning of each month according to the current month.

Or you can use multiple crons to define run dates for each month of the year. In this case, you can manually update the corresponding crons every year according to the actual date.

For example:

schedules:
- cron: "0 0 1-3,5-7 11 1-5" 
  displayName: schedule
  branches:
    include:
    - develop
  always: true

- cron: "0 0 1-3,5-7 12 1-5" 
  displayName: schedule
  branches:
    include:
    - develop
  always: true

For more detailed info, you can refer to this doc about cron definition .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM