我们如何有条件地 运行 CircleCI 工作流程?
How do we conditionally run a CircleCI workflow?
我已经按照 Conditional steps in jobs and conditional workflows 中描述的指南为我的 CircleCI 管道编写了以下代码。
version: 2.1
workflows:
version: 2.1
workflowone:
when:
condition: false
jobs:
- samplejob:
workflowtwo:
when:
condition: true
jobs:
- jobone
jobs:
samplejob:
docker:
- image: buildpack-deps:stable
steps:
- run:
name: Sample Job in WF 1
command: |
echo "This job is in workflowone and the workflow should not run"
jobone:
docker:
- image: buildpack-deps:stable
steps:
- run:
name: Sample Job in WF 2
command: |
echo "This job is in workflowtwo and the workflow should run"
当我 运行 上面的代码输出不是预期的。第一个工作流程不应 运行 因为条件为假。当管道被触发时,两个工作流都开始 运行ning。谁能指出这里遗漏的部分?
根据 CircleCI 文档,工作流(特别是)不接受 condition
键:
Note: When using logic statements at the workflow level, do not
include the condition: key (the condition key is only needed for job
level logic statements).
请参阅此处 logic-statement-examples(滚动到本节底部以查看注释)
我已经按照 Conditional steps in jobs and conditional workflows 中描述的指南为我的 CircleCI 管道编写了以下代码。
version: 2.1
workflows:
version: 2.1
workflowone:
when:
condition: false
jobs:
- samplejob:
workflowtwo:
when:
condition: true
jobs:
- jobone
jobs:
samplejob:
docker:
- image: buildpack-deps:stable
steps:
- run:
name: Sample Job in WF 1
command: |
echo "This job is in workflowone and the workflow should not run"
jobone:
docker:
- image: buildpack-deps:stable
steps:
- run:
name: Sample Job in WF 2
command: |
echo "This job is in workflowtwo and the workflow should run"
当我 运行 上面的代码输出不是预期的。第一个工作流程不应 运行 因为条件为假。当管道被触发时,两个工作流都开始 运行ning。谁能指出这里遗漏的部分?
根据 CircleCI 文档,工作流(特别是)不接受 condition
键:
Note: When using logic statements at the workflow level, do not include the condition: key (the condition key is only needed for job level logic statements).
请参阅此处 logic-statement-examples(滚动到本节底部以查看注释)