Azure DevOps Yml 中的 Concat 变量

问题描述 投票:0回答:1

我想将预定义变量与azure devops中计数器表达式中的文本连接起来

yml

使用

format
似乎有效,但我想知道是否可以用另一种方式连接。

格式

- name: BUILD_NUMBER
  value: $[counter(format('{0}_iis', variables['Build.SourceBranch']), 180)]

Concat(不起作用)

- name: BUILD_NUMBER
  value: $[counter('$(Build.SourceBranch)_iis', 180)]
azure-devops azure-pipelines azure-pipelines-yaml
1个回答
0
投票

第二个 yaml 不起作用,因为您在

counter
表达式中使用了宏语法($(var))。由于您已将
_iis
与值结合使用,因此您可以将
template expression
用于变量:

variables:
- name: BUILD_NUMBER
  value: $[counter('${{ variables['Build.SourceBranch'] }}_iis', 180)]

或者使用第一个表达式,格式为

runtime expression
:

- name: BUILD_NUMBER
  value: $[counter(format('{0}_iis', variables['Build.SourceBranch']), 180)]

请检查文档我应该使用什么语法?供您参考。

© www.soinside.com 2019 - 2024. All rights reserved.