How to Force Gitlab pipeline to fail on condition
if you have a conditional in your Gitlab pipeline stage that checks if something has succeeded or failed, then you can use this to pass or fail your pipeline stage.
Option 1 – Fail on String Found
|
|
This will fail the pipeline if it find a string matching Failure Summary
in a file called log.txt
in the current stage.
Option 2 – Fail on Code Found
Alternatively if you have a file called response.json
that contains 200
or 401
codes, then you can fail the pipeline if a 401
is found:
|
|