Azure YAML if-else 总是失败
我最近正在使用 Azure 进行 CI/CD 设置。目标是让开发人员选择要创建的构建类型,即暂存/生产。
感谢 如何在 Azure DevOps Pipeline 中编写 if else 条件,我添加了以下代码 -
parameters:
- name: selectConfiguration
displayName: Select build configuration
type: string
default: Debug
values:
- Debug
- Release
variables:
- name: config
${{ if eq(variables['parameters.selectConfiguration'], 'Debug') }}:
value: Debug
${{ else }}:
value: Release
这给了我以下结果 -
但无论我在此单选组中选择什么,它总是运行 else 块。即 if-else 总是失败。对理解我在这里做错了什么有帮助吗?
I am recently doing an CI/CD setup using Azure. The goal is to have the developer select the type of build to be created i.e Staging / Prod.
Thanks to How to write if else condition in Azure DevOps Pipeline, I have added following code -
parameters:
- name: selectConfiguration
displayName: Select build configuration
type: string
default: Debug
values:
- Debug
- Release
variables:
- name: config
${{ if eq(variables['parameters.selectConfiguration'], 'Debug') }}:
value: Debug
${{ else }}:
value: Release
This gives me the following result -
But no matter what I select in this radio group, it always run the else block. i.e. the if-else always fails. Any help to understand what I am doing wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试下面的方法,应该可以。我使用相同的逻辑在不同的代理池之间切换。
Try the below, it should work. I am using the same logic to switch between different agent pools.