Reputation: 305
I have created a gitlab pipeline, in which I have created 8 stages. For each stage I have set the property **Allow_failure:true**
so that it will execute remaining stages even if any stage got failed.
Currently, if any stage got failed, then the final pipeline status is showing as "! passed". I want to execute all the stages of the pipeline and if any stage got failed then I want to display pipeline status as failed.
Note: I can't change the value of property Allow_failure.
Please find attached Image for your reference.
Upvotes: 1
Views: 1349
Reputation: 1562
There's no configuration given in Gitlab for this. So we'll mostly have to handle this using scripting.
Idea:
Minimal Snippet:
jobA:
stage: A
allow_failure: true
script:
- echo "building..."
- echo "jobA" > ./completedA
artifacts:
paths:
- ./completedA
jobB:
stage: B
allow_failure: true
script:
- echo "testing..."
- exit 1
- echo "jobB" > ./completedB
artifacts:
paths:
- ./completedB
jobC:
stage: C
allow_failure: true
script:
- echo "deplying..."
- echo "jobC" > ./completedC
artifacts:
paths:
- ./completedC
validate:
stage: Validate
script:
- |
if [[ -f ./completedA && -f ./completedB && -f ./completedC ]]; then
echo "All stages were completed"
else
echo "Stages were not completed"
exit 1
fi
stages:
- A
- B
- C
- Validate
Upvotes: 2