Realiza un curl, recupera la respuesta, busca si aparece la palabra ERROR en la response, cuenta cuantas veces ocurre y si ocurre envía un exit 2 para que falle. Si 0 es que response no devolvió ERROR en ningún sitio.
echo "============> SonarQube's Quality Gate <============" &&
#Initializing two variables
ERR_COUNT=`curl http://127.0.0.1:9000/api/qualitygates/project_status?projectKey=MyAwesomeProjectKey -L | grep -Eo 'ERROR' | wc -l`
#Check whether they are equal
if [ $ERR_COUNT -eq 0 ]
then
echo "QUALITY GATE PASSED!"
echo $ERR_COUNT
fi
if [ $ERR_COUNT != 0 ]
then
echo "QUALITY GATE NOT PASSED!"
echo $ERR_COUNT
exit 2
fi
Thanks for sharing! I just implemented a similar thing in our pipeline.