我在GitLab上有一个样例pipeline,我希望当任何作业失败时,管道可以停止。以下是我用于复制此场景的代码。虽然管道显示为失败状态,但是即使在失败阶段后,作业仍会继续运行。示例请参见附图。
stages:
- unittest
- coverage_test
- static_code_analysis
variables:
skip_integration:
value: 'false'
description: "This variable for skipping integration tests"
skip_migration:
value: 'false'
unittest:
stage: unittest
script:
- echo "testing the code"
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
when: always
- if: '$skip_integration == "true"'
when: never
- if: '$skip_integration == "false"'
when: always
lint_test:
stage: static_code_analysis
allow_failure: false
script:
- echo "this is a test"
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
when: always
- if: '$skip_integration == "true"'
when: never
- if: '$skip_integration == "false"'
when: always
- when: on_success
coverage_test:
stage: coverage_test
script:
- echo00 "this is test again"
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
when: always
- if: '$skip_integration == "true"'
when: never
- if: '$skip_integration == "false"'
when: always
- when: on_success
但是管道在失败时并不停止。