Buuuuuuuuun
Buuuuuuuuun

Reputation: 25

Azure Pipelines Schedule to Run Only Few Days a Month

Is there a way to customize the pipeline scheduling options in Azure to have it run only the second week of each month?

I know you can schedule it to run on individual days of the week, but I cannot figure out how I would do this on a monthly scale.

Upvotes: 2

Views: 10461

Answers (3)

Walter
Walter

Reputation: 3058

Can I do this if my pipeline was made as a classic/GUI based, and not as a YAML pipeline?

In the classic pipelines, you can only set scheduled triggers for each week. As far as I know, you can not have it run only the second week of each month in the classic pipelines. However, you can set schedule triggers in yaml pipeline and use it to trigger your classic pipeline.

Here is the sample if you are going to use a YAML pipeline:

schedules:
- cron: "0 0 8-14 * *" 
  displayName: schedule
  branches:
    include:
    - main
  always: true

In this example:

  • The pipeline will be triggered from the 8th to the 14th of this month. You need to update the date each month.
  • always: true means run even when there are no code changes.
  • Agree with iikkoo that if you want to run your pipeline by only using scheduled triggers, you must disable PR and continuous integration triggers by specifying pr: none and trigger: none in your YAML file.
  • You can add a build completion trigger in this yaml pipeline to trigger your classic pipeline: enter image description hereenter image description here

Please find more detailed information about Configure schedules for pipelines in the document.

Upvotes: 5

iikkoo
iikkoo

Reputation: 2856

You can achive this by creating a scheduling trigger in your YAML config. Note tough, you must disabled PR and CI triggers to run your pipeline by using scheduled triggers.

You disable the trigger by setting pr: none and trigger: none. Then you define the schedule using cron syntax.

schedules:
- cron: "0 0 1/14 * *" # At 00:00 on every 14th day-of-month from 1 through 31.
  displayName: Second week of each month
  branches:
    include:
    - master
    ...

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/scheduled-triggers?view=azure-devops&tabs=yaml

https://github.com/atifaziz/NCrontab/wiki/Crontab-Expression

https://crontab.guru/

Upvotes: 1

Kyle J V
Kyle J V

Reputation: 603

It doesn't seem to do so in the UI, but you can still trigger the build via an API call on your own schedule. https://learn.microsoft.com/en-us/rest/api/azure/devops/build/builds/queue?view=azure-devops-rest-6.1

Upvotes: 0

Related Questions