Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ramingar/52c6417501ef147765de7452615b30f3 to your computer and use it in GitHub Desktop.
Check SonarQube's Quality Gate from TeamCity's build step #sonarqube #teamcity #qualitygate #quality #gate #ci #continousintegration

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
@Netznarkose
Copy link

Thanks for sharing! I just implemented a similar thing in our pipeline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment