【发布时间】:2021-08-05 14:04:44
【问题描述】:
我正在尝试使用在 Azure 管道中的 if 语句中使用日志记录命令在脚本中设置的变量,如下所示,但是,它采用初始值。
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
你知道是否有可能实现这种行为吗?
【问题讨论】:
-
我已经接受了答案。
标签: azure-devops yaml azure-pipelines azure-pipelines-yaml