Azure DevOps UI provides an option to trigger multiple days or once a week. We know that many times we need to execute Azure DevOps pipeline triggers once a month, or twice a month, and this can be done using Cron Expressions in Azure DevOps.
Azure DevOps uses NCronTabto evaluate cron expressions, so advanced expressions are not fully supported by Azure DevOps. However, most of the expression is supported so it does the job.
In this tutorial, I have explained step by step how to configure Cron Scheduler in Mircosoft Azure DevOps.
The tool NCrontab Expression Tester is very helpful to evaluate cron expressions, especially when we consider Azure DevOps. There are many tools I suggest not using because when I tried on that the tool it evaluated successfully but it caused an error in Azure DevOps. The reason is Azure DevOps is supporting only NCronTab basic expressions since the tool is built on the same which is helpful to us. Let's say thanks to this guy.
Step-by-Step Guide to Schedule Pipeline Build or Release using Cron Job or Cron Expressions
Let’s consider my requirement is I want to schedule build First Sunday of every month.
There are two things you need to consider here:
The pipeline which you have already created, let’s say some deployment release pipeline (Example: MyRelease Pipeline).
The new Pipeline (let's call it as Scheduler Pipeline this is build) triggers the above Pipeline, i.e., MyRelease Pipeline (Pipeline mentioned Point No. 1).
In a simple way, Scheduler Pipeline triggers the MyRelease Pipeline.
In other words, you have already created the MyRelease Pipeline (Point no. 1) and you are looking for that pipeline to be triggered in specific intervals that will be done by Scheduler Pipeline.
Let’s see how to trigger My Release Pipeline from Scheduler Pipeline.
Step 1: Create a New Pipeline, i.e., Scheduler Pipeline
Navigate to Azure DevOps page > Hover on Pipelines > Choose Pipelines.
Step 2: Click on New Pipeline
Step 3: Where is Your Code? Section: Choose Use Classic Editor (Refer to Image)
Once you complete step 2, you will be asked to choose the source of your code. Choose Azure Repos Git as your source.
Step 4: Choose Desired Project and Repository
Your YAML file will be saved in this location, so choose as per your requirement.
azure devops,cron job,pipeline,yaml,ci cd pipeline,ci cd tools,tfs,vsts,release,tutorial
Opinions expressed by DZone contributors are their own.