Friday, May 26, 2023
HomeSoftware EngineeringThe right way to Pressure Gitlab pipeline to fail on situation

The right way to Pressure Gitlab pipeline to fail on situation


when you have a conditional in your Gitlab pipeline stage that checks if one thing has succeeded or failed, then you should use this to move 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 known as log.txt within the present stage.

Possibility 2 – Fail on Code Discovered

Alternatively when you have a file known as response.json that accommodates 200 or 401 codes, then you may fail the pipeline if a 401 is discovered:

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

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments