Search code examples
azure-devopscronazure-pipelinesschedule

Azure Pipelines Schedule to Run on specific day is not working


I am trying to configure azure pipeline schedules for running it on a specific day but it is not taking day from 27 to 31.

Please refer below screenshot for better understanding the issue.

enter image description here

trigger:

  • main

pool: vmImage: ubuntu-latest

schedules:

  • cron: "0 18 26-31 * *" displayName: Daily midnight build branches: include:
    • main always: true

enter image description here

Thank you


Solution

  • Executing the pipeline during the last 6 days of the month:

    Since not every month would have 31 days, you want to execute the pipeline on the last 6 days independently from the number of days in the month.

    Azure pipelines use NCrontab which does not provide support for specifying days relative to the end of the month as confirmed by the author in this issue.

    One possible solution (following the suggestion in the following comment) is to use a range of days that include the last six days in the worst case (February ending on the 28th) which you would express as 23-31.

    Then, you must have a task in your pipeline that checks that the current date is within the range of the last 6 days of the current month, and stop the pipeline if it is not.

    As a result, your pipeline will be executed for the last 6 days of the month in the best case and for the last 9 days in the worst case but this will be handled by the additional task explained in the previous sentence.

    Running the pipeline using schedule triggers:

    If you want to run your pipeline by using schedule triggers, you need to disable PR and CI triggers.

    pr: none
    trigger: none