Reputation: 759
I have a deployment pipeline in azure-devops for a repository, and it's working ok with the release schedules. But the problem is, it creates a new release for each scheduled time, even if the artifact is not changing the next day. i.e, if the repository is not being updated for a month, I have around 30 new releases for the same artifact.
The reason we need to have this kind of scheduled deployment is, we bring down all the deployed projects from our target resource group every night, and someone / something needs to deploy the latest release again to the target stages every morning.
I enabled the stage schedule under the pre-deployment conditions and set a time for it (08:00 am), it schedules for 08:00 am for the next day (and deploys). But it looks like it's not triggering another deployment for the following day. (if there is no newer release).
Am I missing something here?
Upvotes: 0
Views: 1001
Reputation: 30393
Release triggered by Scheduled release triggers will create a new release. This is by design and cannot be changed. Check document Releases in Azure Pipelines for more information.
If you want to redeploy to a stage on a schedule without creating a new release. As a workaround you can write a script to call release environment update rest api. And set a task schedule on your machine to run this script.
1, Below is an example to redeploy a stage of a release in powershell script.
You can refer to the steps here to get a Person access Token(PAT).
you can use Release get api to get the Environment Id.
$url ="https://vsrm.dev.azure.com/{organization}/{project}/_apis/Release/releases/{releaseId}/environments/{environmentId}?api-version=5.1-preview.6"
$pat ="{PAT}"
$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($pat)"))
$body='{"status": "inProgress"}'
Invoke-RestMethod -Uri $url -Headers @{authorization = "Basic $base64AuthInfo"} -ContentType "application/json" -Method patch -Body $body
There is another example to redeploy a stage via rest api in this thread. Please check it out.
2, After you have completed above script, you need to set a task schedule to run above script. Please check the detailed steps here to Configure to run a PowerShell Script into Task Scheduler on Windows machine
Upvotes: 2
Reputation: 1151
There is option for release pipeline to set scheduled release only when source has changed.
It may require reorganization of your CI/CD flow or creating new release definition.
Upvotes: 0