简体   繁体   English

Azure DevOps YAML 构建管道 - 设置脚本任务名称

[英]Azure DevOps YAML build pipeline - Set script task name

I have a YAML build pipeline with a simple script task that sets the build configuration based on the branch being built:我有一个带有简单脚本任务的 YAML 构建管道,该任务根据正在构建的分支设置构建配置:

- script: |
    echo Current branch is %BUILD_SOURCEBRANCHNAME%
    if %BUILD_SOURCEBRANCHNAME% == "master" (
        SET BUILD_CONFIG=Release
    ) else (
        SET BUILD_CONFIG=Debug
    )
    echo ##vso[task.setvariable variable=BuildConfiguration]%BUILD_CONFIG%
    echo BuildConfiguration set to '%BUILD_CONFIG%'

This works fine but the task appears in the list as 'CmdLine' and I'd like something a little more descriptive.这工作正常,但任务在列表中显示为“CmdLine”,我想要一些更具描述性的内容。 The example in the MS documentation indicates that I should be able to add a displayName entry to the end: MS 文档中的示例表明我应该能够在末尾添加一个 displayName 条目:

- script: |
    echo Current branch is %BUILD_SOURCEBRANCHNAME%
    if %BUILD_SOURCEBRANCHNAME% == "master" (
        SET BUILD_CONFIG=Release
    ) else (
        SET BUILD_CONFIG=Debug
    )
    echo ##vso[task.setvariable variable=BuildConfiguration]%BUILD_CONFIG%
    echo BuildConfiguration set to '%BUILD_CONFIG%'
    displayName: 'Determine Build Configuration'

However, this fails with 'displayName:' is not recognized as an internal or external command, operable program or batch file.但是,这会失败,因为'displayName:' is not recognized as an internal or external command, operable program or batch file.

Such a simple thing but I've tried everything I can think of and just can't get it to work!这么简单的事情,但我已经尝试了所有我能想到的方法,但无法让它发挥作用!

fix indentation:修复缩进:

- script: |
    echo Current branch is %BUILD_SOURCEBRANCHNAME%
    if %BUILD_SOURCEBRANCHNAME% == "master" (
        SET BUILD_CONFIG=Release
    ) else (
        SET BUILD_CONFIG=Debug
    )
    echo ##vso[task.setvariable variable=BuildConfiguration]%BUILD_CONFIG%
    echo BuildConfiguration set to '%BUILD_CONFIG%'
  displayName: 'Determine Build Configuration'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM