我有一个带有简单脚本任务的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%'
这可以正常工作,但是任务在列表中显示为“ CmdLine”,我想要一些更具描述性的内容。 MS文档中的example表示我应该能够在最后添加一个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'
但是,此操作失败,出现'displayName:' is not recognized as an internal or external command, operable program or batch file.
这很简单,但是我已经尝试了所有我能想到的并且无法正常工作!
答案 0 :(得分:1)
修复缩进:
- 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'