How to Run a Scheduled Nightly Deploy in Azure Pipelines
A schedules cron entry runs the deploy on a fixed timetable, independent of any push.
Add a schedules block with a cron expression and the branch to build. The pipeline runs at each scheduled time and deploys to your target.
Steps
- Add a
schedulesblock with acronexpression (UTC). - List the
branchesto build on the schedule. - Set
always: trueif you want it to run even without new commits. - Deploy to a non-prod environment on the schedule.
azure-pipelines.yml
azure-pipelines.yml
schedules:
- cron: '0 2 * * *'
displayName: Nightly staging deploy
branches:
include: [main]
always: true
pool:
vmImage: ubuntu-latest
steps:
- script: npm ci && npm run build
- task: AzureWebApp@1
inputs:
azureSubscription: 'my-azure-rm'
appName: 'staging-web-app'
package: '$(Build.ArtifactStagingDirectory)/app.zip'Gotchas
- Cron times are UTC; account for daylight saving when picking the hour.
- Without
always: true, a scheduled run is skipped when the branch has no new commits.
Related guides
How to Deploy on a Git Tag With Azure PipelinesTrigger a deploy in Azure Pipelines only when a version tag is pushed by filtering the CI trigger on refs/tag…
How to Deploy to Multiple Regions With a Matrix in Azure PipelinesDeploy the same build to several Azure regions at once in Azure Pipelines with a matrix strategy that fans a…