Skip to content

Instantly share code, notes, and snippets.

@CalamarBicefalo
Created January 5, 2018 11:34
Show Gist options
  • Save CalamarBicefalo/e6cd2cffe4caa8aeff7fcbb67cf4e782 to your computer and use it in GitHub Desktop.
Save CalamarBicefalo/e6cd2cffe4caa8aeff7fcbb67cf4e782 to your computer and use it in GitHub Desktop.
Script to check whether a jenkins build is broken or not
#!/bin/sh
build_info=$(curl -s http://<jenkinshost>/job/<your-job>/lastBuild/api/json --user <read-only-username>:<committable-password>)
job_status=`echo $build_info | grep "\"result\":\"SUCCESS\""`
if [ -n "$job_status" ]
then
continue;
else
while true; do
read -p "The latest build is broken or a build is already in progress. Is your commit fixing a broken build? (y or n) " yn
case $yn in
[Yy] ) echo "Thanks!"; break;;
[Nn] ) echo "Please wait until the build is done!"; exit 1;;
* ) echo "Please answer y or n.";;
esac
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment