Fix skipped status of DAG pipelines
What does this MR do?
Related to #213080 (closed)
We have 3 ways for a job to be skipped.
1. When the job is `when: on_success` and status of previous/needs jobs is "failure".
build:
stage: build
script: exit 1
test:
stage: test
script: exit 0
deploy:
stage: deploy
script: exit 0
needs: [test]
Result:
In this example, build
fails, test
skips, and deploy
skips. Then the pipeline fails.
Why does deploy
skip? That's because the dependent job test
does not run at all.
This is our main rule for "needs" here.
2. When the job is `when: on_failure` and status of previous/needs jobs is "success".
build:
stage: build
script: exit 0
test:
stage: test
when: on_failure
script: exit 0
deploy:
stage: deploy
script: exit 0
needs: [test]
Result:
In this example, build
succeeds, test
skips, and deploy
skips. Then the pipeline succeeds.
Why does deploy
skip? That's because the dependent job test
does not run at all. Right?
This is our main rule for "needs" here.
3. When the job is `when: manual`.
I haven't touch it in this MR because it is discussed in the other issue.
What's the ~bug in this issue?
1. Bug 1
build_1:
stage: build
script: exit 0
build_2:
stage: build
script: exit 1
test:
stage: test
script: exit 0
deploy:
stage: deploy
script: exit 0
needs: [build_1, test]
Result:
In this example, build_1
succeeds, build_2
fails, test
skips, and deploy
runs and succeeds. Then the pipeline fails.
Why does deploy
run? That's the ~bug in this issue. It should not run, because one of the needs (test
) does not run at all.
That was our main rule for "needs".
2. Bug 2
build_1:
stage: build
script: exit 0
build_2:
stage: build
script: exit 0
test:
stage: test
script: exit 0
when: on_failure
deploy:
stage: deploy
script: exit 0
needs: [build_1, test]
Result:
In this example, build_1
succeeds, build_2
succeeds, test
skips, and deploy
runs and succeeds. Then the pipeline succeeds.
Why does deploy
run? That's the ~bug in this issue. It should not run, because one of the needs (test
) does not run at all. Right?
That was our main rule for "needs".
This solution is just to fix those bugs, not touch the existing behaviors.
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team