Can you change the timezone of a scheduled yaml pipeline in Azure DevOps?

Viewed 251

We have a yaml pipeline in Azure Devops that runs automatically twice a day, as described here:

https://docs.microsoft.com/en-us/azure/devops/pipelines/process/scheduled-triggers?view=azure-devops

The documentation is quite clear that you schedule a job using cron syntax, and that it is always in the UTC timezone. Which is irritating, because daylight savings changes. I found a feature request at Microsoft here:

https://developercommunity.visualstudio.com/t/schedule-yaml-pipeline-trigger-with-local-timezone/809673

but it doesn't seem to be going anywhere fast. I wondered if some clever person hadn't found a workaround to tweak the timezone of the schedule?

1 Answers

As described in the official document, it is not possible to use DST time in the YAML trigger.

But we can find a way to bypass this limitation, for example, you can write a program on a machine based on daylight saving time, and periodically trigger the following code to run:

import requests
import json

url = "https://dev.azure.com/<Your Organization Name>/<Your Project Name>/_apis/pipelines/<Your Pipeline ID>/runs?api-version=6.0-preview.1"

payload = json.dumps({
  "resources": ""
})
headers = {
  'Authorization': 'Basic <PAT>',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

In this way, it should trigger the pipeline as you want.

Related