如果同一分支有另一个匹配的管道,则不会执行分支管道的步骤。请检查代码,您可能会明白这一点。我需要使用任何条件吗?我也尝试过
if
条件,没有运气。请帮忙解决这个问题。
definitions:
steps:
- step: &build-test
name: 'Build and test'
script:
- echo "Your build and test goes here..."
- step: &Lint
name: 'Lint'
script:
- echo "Your linting goes here..."
- step: &Securityscan
name: 'Security scan'
script:
- echo "Your security scan goes here..."
- step: &Deploy-step
name: 'Deploy-step'
deployment: staging
script:
- echo "your deployment"
pipelines:
branches:
'{dev,rev}': # this runs
- step: *build-test
- step: *Lint
dev: # not executing
- step: *Securityscan
rev: # not executing
- step: *Deploy-step
name: "Deploying to prod"
管道不支持你正在尝试做的事情。它选择一个分支定义,可能是第一个匹配的分支定义,然后运行它的步骤。其余的被忽略,没有添加
正如@Randommm 所解释的,与您可能更熟悉的其他 CI 系统(例如 GitLab)不同,只会触发与您的分支匹配的第一个管道。如果你想在不同的管道中重用步骤,那些 yaml 锚点已经非常少了。
此外,请注意您如何覆盖锚点:部署步骤的语法错误。 (可能你没有意识到,因为那个管道从未被触发过)
pipelines:
dev:
- step: *build-test
- step: *Lint
- step: *Securityscan
rev:
- step: *build-test
- step: *Lint
- step:
<<: *Deploy-step
name: "Deploying to prod"
deployment: production