Search code examples
azure-devopscronyamlazure-pipelinesazure-yaml-pipelines

Change minutes dynamically in CronTab on Azure DevOps with Pipeline Variable


I have a yaml pipeline where I would like to set the CRON minutes with a Variable Pipeline to avoid making commits and pull requests.

When I try to do something like this I get syntax errors:

schedules:
- cron: "*/$(PipelineVariable) * * * *"
  displayName: Daily midnight build

It doesn't work inside the string - this is the error I get:

Encountered error(s) while parsing pipeline YAML: /execution.yaml (Line: 8, Col: 4):
Error while validating cron input. Improperly formed cron syntax: '*/$(Minutes) * * * *'.

And it doesn't work outside either.

/execution.yaml (Line: 8, Col: 4):
Error while validating cron input. Improperly formed cron syntax: '$(CronTab)'.

Why doesn't it accept the syntax from a Pipeline variable?


Solution

  • The following documentation has mentioned "You cannot use pipeline variables when specifying schedules.":

    https://learn.microsoft.com/en-us/azure/devops/pipelines/process/scheduled-triggers?view=azure-devops&tabs=yaml

    enter image description here

    You may submit a suggestion at website below:

    https://developercommunity.visualstudio.com/content/idea/post.html?space=21