diff options
author | Jonas Gunz <himself@jonasgunz.de> | 2021-04-07 17:41:27 +0200 |
---|---|---|
committer | Jonas Gunz <himself@jonasgunz.de> | 2021-04-07 17:41:27 +0200 |
commit | d56055580c298fe2b6c4d9c0490ee08929810c01 (patch) | |
tree | ffbdf4d6c547cb540b4e7cf482d7a437c2a11c52 /check_jenkins_job | |
parent | 641e78fdf100c14efae22a9c2b440810e14f35de (diff) | |
download | monitoring_custom-d56055580c298fe2b6c4d9c0490ee08929810c01.tar.gz |
check_jenkins_job
Diffstat (limited to 'check_jenkins_job')
-rwxr-xr-x | check_jenkins_job | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/check_jenkins_job b/check_jenkins_job new file mode 100755 index 0000000..757bc7a --- /dev/null +++ b/check_jenkins_job @@ -0,0 +1,27 @@ +#!/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 + +shift 3 + +CURL_OUT=$( curl -s $@ $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 |