2018-04-26 16:39:31 +02:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
# This script do the following :
|
|
|
|
|
# Use jenkins-cli.jar
|
|
|
|
|
# Verify if an update is available for Jenkins plugins.
|
|
|
|
|
# Create a file you need to monitore.
|
|
|
|
|
#
|
|
|
|
|
# How-to use it ?
|
|
|
|
|
# Run it with `jenkins_check_update
|
|
|
|
|
# Add a symlink to /etc/cron.daily
|
|
|
|
|
# ln -s $(pwd)/jenkins_check_update /etc/cron.daily/
|
|
|
|
|
|
|
|
|
|
JENKINS_HOME="/var/lib/jenkins"
|
|
|
|
|
JENKINS_CLI_JAR="${JENKINS_HOME}/war/WEB-INF/jenkins-cli.jar"
|
|
|
|
|
JENKINS_AUTH_FILE="/root/.jenkins.auth"
|
|
|
|
|
|
|
|
|
|
JENKINS_PLUGIN_UPDATE_LOG="${JENKINS_HOME}/.update_plugin"
|
|
|
|
|
|
|
|
|
|
if [ ! -f "${JENKINS_CLI_JAR}" ]; then
|
|
|
|
|
printf '%b\n' "Jenkins-cli (${JENKINS_CLI_JAR}) does not seem to be available."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ ! -f "${JENKINS_AUTH_FILE}" ]; then
|
|
|
|
|
printf '%b\n' "Jenkins authentication file (${JENKINS_AUTH_FILE}) does not seem to be available."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2018-04-26 17:08:14 +02:00
|
|
|
|
cd "$(dirname ${JENKINS_AUTH_FILE})" || exit
|
2018-04-26 16:39:31 +02:00
|
|
|
|
# Verify if updates are availables for plugins
|
|
|
|
|
if java -jar "${JENKINS_CLI_JAR}" -s http://127.0.0.1:8080 -auth @.jenkins.auth list-plugins | grep -i -q -- "(.*)$"
|
|
|
|
|
then
|
|
|
|
|
touch "${JENKINS_PLUGIN_UPDATE_LOG}"
|
|
|
|
|
#printf '%b\n' "Please upgrade plugins"
|
|
|
|
|
else
|
2018-05-04 16:58:18 +02:00
|
|
|
|
rm -f -- "${JENKINS_PLUGIN_UPDATE_LOG}"
|
2018-04-26 16:39:31 +02:00
|
|
|
|
#printf '%b\n' "Nothing to do"
|
|
|
|
|
fi
|
2018-05-02 16:10:23 +02:00
|
|
|
|
cd - > /dev/null || exit
|
2018-04-26 16:39:31 +02:00
|
|
|
|
|
|
|
|
|
exit 0
|