diff options
Diffstat (limited to 'plugins/check_jenkins_job')
-rwxr-xr-x | plugins/check_jenkins_job | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/plugins/check_jenkins_job b/plugins/check_jenkins_job new file mode 100755 index 0000000..ab40f87 --- /dev/null +++ b/plugins/check_jenkins_job @@ -0,0 +1,29 @@ +#!/bin/bash + +# Usage: check_jenkins_job <jenkins-url> <view> <job> <curl opts ...> + +if [ "$#" -lt 3 ]; then + echo "Usage: $0 <jenkins-url> <view> <job> <curl opts ...>" + exit 3 +fi + +JENKINS_URL=$1 +VIEW=$2 +JOB=$3 +PASS=$5 +USER=$4 + +shift 5 + +CURL_OUT=$( curl -s --basic -u "$USER:$PASS" $@ $JENKINS_URL/view/$VIEW/job/$JOB/lastBuild/api/json ) + +RESULT=$( jq -r .result <<< $CURL_OUT ) +ID=$( jq -r .displayName <<< $CURL_OUT ) + +if [ "$RESULT" = "SUCCESS" ]; then + echo JOB OK: $JOB $ID succeeded + exit 0 +fi + +echo JOB CRITICAL: $JOB $ID failed +exit 2 |