【发布时间】:2021-09-08 01:18:38
【问题描述】:
如果满足以下条件,我想写:
- 运行 ax 分析应设置为 true
- 构建原因应该是拉取请求
- 源分支应该是开发分支(当用户选择任何其他分支时[ex:release] ax 不应该运行)
- 自定义标签值不应为空
我尝试了以下条件
- ${{ if or(eq(parameters.axe_flag, true) , eq(variables['Build.Reason'], 'PullRequest')) }}:
- ${{ if and(not(eq(parameters.cust_tagName, 'null' )) ,startsWith(variables['Build.SourceBranch'], 'refs/heads/develop')) }}:
condition: and(succeeded(), or(startsWith(variables['Build.SourceBranch'], 'refs/heads/develop'), startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'), startsWith(variables['Build.SourceBranch'], 'refs/heads/develop-map')))
如果条件不起作用,则为多个。继续低于错误
Exactly 1 parameter(s) were expected following the directive 'if'. Actual parameter count: 2
/templates/build.yml@templates (Line: 40, Col: 3): Unexpected value '${{ if or(eq(parameters.sonarqube_flag, true) , eq(variables['Build.Reason'], 'PullRequest')), and(not(eq(parameters.cust_tagName, 'null' )) ,startsWith(variables['Build.SourceBranch'], 'refs/heads/develop')) }}'
/templates/build.yml@templates: (Line: 46, Col: 14, Idx: 1828) - (Line: 46, Col: 14, Idx: 1828): Mapping values are not allowed in this context.
当我添加带有 and 条件的第二个 if 语句时,第一个带有 or 条件的 if 语句可以完美运行而没有错误,继续收到以下错误。关于如何处理多种情况的任何建议都会非常有帮助。提前致谢。
【问题讨论】:
-
你能告诉你完整的管道吗?
-
不幸的是,我无法分享完整的管道。您能否就如何处理多个 if 条件提出建议。 @KrzysztofMadej
标签: azure-devops azure-pipelines-yaml