1

We are trying to queue from code a build but that should not run instantly but in the evening as our build pipeline is quite free in the evening and this job does not need to be run right away.

We are queuing around 20 or those builds on a daily basis and right now it is unfortunately blocking other builds. I know that we can use build priorities but it is not good enough as the build we want to "postpone" takes quite a long time and would block other builds if it would be started before the high importance build.

We also saw that it is possible to create a schedule but this sounds more like a build that should reoccur where we need the build to run only once.

2 Answers2

0

Azure Devops: Queue a build to run in the evening

Trigger build only once is not available for now. As you saw, there only as working days, time and time zone for schedule.

There has an user voice Scheduled builds - More flexible timing configuration which suggest more flexible time configuration including. You can vote and follow up for this user voice.

As the comment on that thread, we could Use cron syntax to specify schedules in a YAML file. As test, we can get a more detailed timing configuration, but we still could not schedule the build to run only once.

As workaround, we could schedule the build on a certain day of the week, after schedule build completed, Then we could disable the schedule manually or using the tool Azure DevOps CLI.

Hope this helps.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • 1
    The last link says "Azure DevOps CLI", but it redirects to Azure Batch section. How is Azure Batch related to Azure DevOps pipelines? Could you please elaborate? – Jakub Jankowski Jul 10 '19 at 11:45
  • @JakubJankowski, Sorry for the error link. I have updated it, we could use Azure CLI and scheduled task to do this, for the details, you can refer this thread https://stackoverflow.com/questions/52429366/azure-devops-is-it-possible-to-schedule-a-release-for-a-specific-day-and-time/54525315#54525315 or the answer provided by gigatt. – Leo Liu Jul 11 '19 at 02:10
0

There is a work-around to achieve running a build once at an appointed time using Azure CLI and CMD scheduled task. You can try to follow below steps.

1, you need to install Azure CLI. You can follow the steps in this blogs to get started with Azure CLI. [blog]:https://devblogs.microsoft.com/devops/using-azure-devops-from-the-command-line/

2, Create a CMD script like below and save it to your local disk, For more information about az pipelines commands go to https://learn.microsoft.com/en-us/cli/azure/ext/azure-devops/pipelines/build?view=azure-cli-latest#ext-azure-devops-az-pipelines-build-queue

az pipelines build queue --definition-name your-build-definition-name -o table

3,create a scheduled CMD task script using schtask.exe like below example, for more information visit https://www.windowscentral.com/how-create-task-using-task-scheduler-command-prompt

schtasks /create /tn "give-your-task-a-name" /tr "the-location-of-the-scripts-file-you-created-in-previous-step" /sc ONCE /st specify-the-time-to-run-your-build

You can save this script to your local disk too, Next time you can just run this scripts when you want to schedule your build to run in the evening.

Hope above steps can help you, This workaround seems tedious and need a little effort. But it is an once and for all work.

gigatt
  • 105
  • 7