From d41e8980981898b3f26b0f0c257143c5d9cd07ec Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Fri, 1 Oct 2021 00:44:13 +0200 Subject: check_jenkins_job cleanup --- plugins/check_jenkins_job | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/check_jenkins_job b/plugins/check_jenkins_job index ab40f87..5f075bd 100755 --- a/plugins/check_jenkins_job +++ b/plugins/check_jenkins_job @@ -15,15 +15,18 @@ USER=$4 shift 5 -CURL_OUT=$( curl -s --basic -u "$USER:$PASS" $@ $JENKINS_URL/view/$VIEW/job/$JOB/lastBuild/api/json ) +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 ) +RESULT=$( jq -r .result <<< "$CURL_OUT" ) +RUNNING=$( jq -r .building <<< "$CURL_OUT" ) +ID=$( jq -r .displayName <<< "$CURL_OUT" ) if [ "$RESULT" = "SUCCESS" ]; then - echo JOB OK: $JOB $ID succeeded + echo "JOB OK: $JOB $ID succeeded" exit 0 +elif [ "$RUNNING" = "true" ]; then + echo "JOB OK: $JOB $ID is running" fi -echo JOB CRITICAL: $JOB $ID failed +echo "JOB CRITICAL: $JOB $ID failed" exit 2 -- cgit v1.2.3