I am trying to use a variable that is set in a script using a logging command in an if statement in an Azure pipeline as shown below, however, it takes the initial value.
parameters:
- name: aParameter
type: string
default: dothis
values:
- dothis
- dothat
variables:
- name: aVariable
value: 0
schedules:
- cron:
...
steps:
- bash: |
updateVariable=$(<an expression>)
echo "##vso[task.setvariable variable=aVariable]$updateVariable"
displayName: Set the variable value
- bash: echo $(aVariable) # It actually prints the updated value
- ${{ if or(eq(parameters.aParameter, 'dothis'), and(eq(variables['Build.Reason'], 'Schedule'), lt(variables['aVariable'], 30))) }}:
- template: templates/do-this.yaml
- ${{ if or(eq(parameters.aParameter, 'dothat'), and(eq(variables['Build.Reason'], 'Schedule'), ge(variables['aVariable'], 30))) }}:
- template: templates/do-that.yaml
Do you know if it is possible to achieve this behavior?