Last week I presented how you can create easily Azure DevOps Pipeline on YAML basis. Today I’m gonna show you how you can do this on scheduled way. (you can find the video version end of this post)

I know, several times you need to execute a scripts in every hours or days. Maybe until now you had a dedicated machine, where you did this. But from now you can eliminate that and you can use Azure DevOps Pipeline with time trigger for it.

In my post from last week (HandsOn – Azure Pipelines with YAML), you can read how you can prepare a project on GitHub and Azure DevOps. I made some tiny changes for Today. I mean, I put the code to an Azure DevOps repository. So you can use the guide from last week for preparation. Note: if you have an azure DevOps Repository, there is a fork at point 3 under Step 5. Here you should choose Azure Repos Git option.

The further steps are almost same. When you open the pipeline you can see the code we made last time.

Now we schedule our code from YAML. For this go to our Visual Studio Code where I opened the code after the git clone action. Open our YAML file. Insert the time trigger section to top of the existing YAML file.

always: true – this is important if you really want to execute this code scheduled. Without it the trigger won’t work well.

cron – this is the standard crontab related scheduling. If you are not familiar with this configuration, open the https://crontab.guru in your browser which helps you to find the right configuration. Be careful with timing because if you schedule this for a special date and time – like 10AM every day, in Azure DevOps it will run 10AM every day in UTC.

Last but not lease please enter a user friendly display name for scheduling. This is useful, because you can use multiple schedules for your pipeline.

Save this file, then push back to your repository. Here you should know the pipeline will run immediately when you commit the changes to repo. This is the normal behavior here.