I have an Azure DevOps pipeline that is used to rotate some keys. There are two primary requirements -
- Only rotate one key at at time.
- Any key can be rotated ad-hoc through a manual run.
To do this, I plan to use a cron schedule that runs on various days. A parameter should then be used with the default being set to a specific 'Key Kind' based on the day of the week. Using a parameter means that a user can also specify the key to rotate when running the pipeline manually.
Unfortunately what I've come up with doesn't work. Each of the four expressions in the parameters yeild the following error -
A template expression is not allowed in this context
According to the documentation...
Compile time expressions can be used anywhere
...but that does not seem to be correct. I'm hoping that I'm missing something rather than the documentation being incorrect, but either way I'm not sure how I can achieve my goal.
pr: none
trigger: none
schedules:
- cron: 0 2 * * 0-3,6
displayName: Rotate a key
branches:
include:
- develop
always: true
parameters:
- name: keyKinds
displayName: Key Kinds
type: string
${{ if not(in(format('{0:dddd}', pipeline.startTime), 'Sunday', 'Monday', 'Tuesday')) }}:
default: primary
${{ if eq(format('{0:dddd}', pipeline.startTime), 'Sunday') }}:
default: secondary
${{ if eq(format('{0:dddd}', pipeline.startTime), 'Monday') }}:
default: primaryReadonly
${{ if eq(format('{0:dddd}', pipeline.startTime), 'Tuesday') }}:
default: secondaryReadonly
values:
- primary
- secondary
- primaryReadonly
- secondaryReadonly