Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
modules/profile/files/monitoring/local/check_jenkins_plugins
#!/bin/bash
# HEADER: managed by puppet, do NOT edit manually!
set -u
if [ ! -e /lib/systemd/system/jenkins.service ] ; then
# Check should be enabled only on jenkins master hosts
exit 0
fi
script=$(basename "$(readlink -f "$0")")
if pgrep -f list-plugins >/dev/null; then
result="Check is already running"
rc=1
else
cli=/var/lib/jenkins/jenkins-cli.jar
# shellcheck disable=SC2016
awk_script='BEGIN {ORS=", "} { if ( $NF ~ /^\(/ ) print $1}'
updates=$(java -jar ${cli} -ssh -user jenkins -i /var/lib/jenkins/.ssh/id_rsa_jenkins -s http://localhost:8080 list-plugins | awk "${awk_script}")
if [ -n "${updates:-}" ] ; then
num=$(echo "${updates}" | wc -w)
result="Plugin updates (${num}): ${updates}"
rc=1
else
result="No plugin updates"
rc=0
fi
fi
echo "${rc:-2} ${script} - ${result:-UNKNOWN ERROR}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.