Azure 管道 yml:如何打印出变量的值

时间:2021-05-06 10:12:44

标签: azure-devops azure-pipelines azure-pipelines-yaml

似乎 name 是一个特殊的魔法变量,它以某种方式用于我的输出目录。 (此行为是否记录在任何地方?)

我正在尝试设置它。

鉴于编写 Azure 管道 yml 非常困难,我不太可能把它弄对。在没有任何形式的调试的情况下,我想添加一个打印语句,以便我可以看到值。

怎么样?

  ${{ if eq(variables['Build.SourceBranchName'], 'master') }}:
    buildConfiguration: 'Release'
    tag: ''
    
  ${{ if ne(variables['Build.SourceBranchName'], 'master') }}:
    buildConfiguration: 'Debug'
    tag: ${{ format('-{0}', variables['Build.SourceBranchName']) }}

# How do you do string concatenation in yml? Do I need to do `format` like above?
name: $(Build.BuildId)$(tag)

steps:

- script: echo "name is $(name)"

但是输出是

Generating script.
Script contents:
echo "name is $(name)"
...
name is $(name)"

有可能完成这项工作吗?怎么样?

1 个答案:

答案 0 :(得分:0)

name 变量用于 Build.BuildNumber 值(请参阅 here)。

所以只需打印它:

- script: echo "name is $(Build.BuildNumber)"
相关问题