Skip to content

Instantly share code, notes, and snippets.

@tobiisdesired
Last active May 9, 2018 21:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobiisdesired/bb8aebdaf9db0c01ad27 to your computer and use it in GitHub Desktop.
Save tobiisdesired/bb8aebdaf9db0c01ad27 to your computer and use it in GitHub Desktop.
This is a simple bash script to monitor multiple Jenkins CI jobs for build failures. The script requires rsstail to be installed. Depending on your environment it is also possible to specify a notification command like /usr/bin/notify-send to show status updates directly on your desktop. Usage: ./jenkins-notify jenkins_url job_name...
#! /usr/bin/env bash
JENKINS_SERVER=${1}
shift
JOBS=$*
CHECK_INTERVAL=30
NOTIFY_CMD=
# NOTIFY_CMD=/usr/bin/notify-send
command -v rsstail >/dev/null 2>&1 || { echo >&2 "This script requires rsstail to be installed. See http://www.vanheusden.com/rsstail"; exit 1; }
trap "kill -TERM -$$" SIGINT SIGTERM
while read line; do
if grep -q -v 'stable' <<< ${line}; then
if [ -n "${NOTIFY_CMD}" ]; then
$NOTIFY_CMD "${line:7}"
else
echo "${line:7}"
fi
fi
done < <(for JOB in ${JOBS}; do \
JENKINS_FEED_URL="${JENKINS_SERVER}/view/All/job/${JOB}/rssAll"; \
rsstail -P -n 10 -i "${CHECK_INTERVAL}" -u "${JENKINS_FEED_URL}" & \
done) &
wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment