Power Gitlab pipeline to fail on situation



you probably have a conditional in your Gitlab pipeline stage that checks if one thing has succeeded or failed, then you should utilize this to cross or fail your pipeline stage.

Possibility 1 – Fail on String Discovered

if cat log.txt | grep "Failure Abstract" ; then exit 1 ; else exit 0 ; fi

This can fail the pipeline if it discover a string matching Failure Abstract in a file referred to as log.txt within the present stage.

Possibility 2 – Fail on Code Discovered

Alternatively you probably have a file referred to as response.json that accommodates 200 or 401 codes, then you possibly can fail the pipeline if a 401 is discovered:

if cat response.json | grep 401 ; then exit 1; else exit 0 ; fi