diff options
author | Giorgio Peron <giorgio.peron@gmail.com> | 2011-07-23 21:55:25 -0500 |
---|---|---|
committer | Niels Horn <niels.horn@slackbuilds.org> | 2011-08-11 20:28:36 -0300 |
commit | c1ddce54cbe423d1d875b0e15356507c2ed72cdb (patch) | |
tree | 32a9564778ead706b9f5cf70dbbeae3f4b899635 /system/jenkins | |
parent | cc71fc06d022150180e4b96148d9931c52054c59 (diff) |
system/jenkins: Added (automated job monitor)
Thanks to Vincent Batts for some configs :-)
Signed-off-by: Robby Workman <rworkman@slackbuilds.org>
Diffstat (limited to 'system/jenkins')
-rw-r--r-- | system/jenkins/README | 5 | ||||
-rw-r--r-- | system/jenkins/doinst.sh | 28 | ||||
-rw-r--r-- | system/jenkins/files/jenkins.bin.sh | 2 | ||||
-rw-r--r-- | system/jenkins/files/jenkins.conf | 68 | ||||
-rw-r--r-- | system/jenkins/files/jenkinsd.sh | 119 | ||||
-rw-r--r-- | system/jenkins/files/logrotate.jenkins | 13 | ||||
-rw-r--r-- | system/jenkins/files/rc.jenkins | 82 | ||||
-rw-r--r-- | system/jenkins/jenkins.SlackBuild | 93 | ||||
-rw-r--r-- | system/jenkins/jenkins.info | 10 | ||||
-rw-r--r-- | system/jenkins/slack-desc | 19 |
10 files changed, 439 insertions, 0 deletions
diff --git a/system/jenkins/README b/system/jenkins/README new file mode 100644 index 0000000000000..348e3da7ed43c --- /dev/null +++ b/system/jenkins/README @@ -0,0 +1,5 @@ +Jenkins monitors executions of repeated jobs, such as building a software +project or jobs run by cron. Among those things, current Jenkins focuses on the +following two jobs: +1. Building/testing software projects continuously +2. Monitoring executions of externally-run jobs, diff --git a/system/jenkins/doinst.sh b/system/jenkins/doinst.sh new file mode 100644 index 0000000000000..9f1e12ada2af3 --- /dev/null +++ b/system/jenkins/doinst.sh @@ -0,0 +1,28 @@ +config() { + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + if [ ! -r $OLD ]; then + mv $NEW $OLD + elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then + rm $NEW + fi +} + +preserve_perms() { + NEW="$1" + OLD="$(dirname $NEW)/$(basename $NEW .new)" + if [ -e $OLD ]; then + cp -a $OLD ${NEW}.incoming + cat $NEW > ${NEW}.incoming + mv ${NEW}.incoming $NEW + fi + config $NEW +} + +preserve_perms etc/rc.d/rc.jenkins.new +config etc/jenkins/jenkins.conf.new +config etc/logrotate.d/jenkins.new +config var/log/jenkins/jenkins.log.new +config var/log/jenkins/jenkins_console.log.new +rm -f var/log/jenkins/*.new + diff --git a/system/jenkins/files/jenkins.bin.sh b/system/jenkins/files/jenkins.bin.sh new file mode 100644 index 0000000000000..270ce32d65c21 --- /dev/null +++ b/system/jenkins/files/jenkins.bin.sh @@ -0,0 +1,2 @@ +#!/bin/sh +java -jar /usr/share/jenkins/jenkins.war ${1+"$@"} diff --git a/system/jenkins/files/jenkins.conf b/system/jenkins/files/jenkins.conf new file mode 100644 index 0000000000000..fbdbcb875b9ed --- /dev/null +++ b/system/jenkins/files/jenkins.conf @@ -0,0 +1,68 @@ +## jenkins configuration setup file +# +## Copyright 2008,2009 Vincent Batts, Birmingham, AL, USA +## Copyright 2010,2011 Vincent Batts, Vienna, VA, USA +## vbatts@hashbangbash.com, http://hashbangbash.com/ +## All rights reserved. +## +## Redistribution and use of this script, with or without modification, is +## permitted provided that the following conditions are met: +## +## 1. Redistributions of this script must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## +## THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED +## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +## EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +## OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +## WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +## OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +## ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +## Java defaults to `which java` +#JAVA=/usr/lib/java/bin/java + +## system user for jenkins daemon (default to 'jenkins') +JENKINS_USER="jenkins" + +## set the http route prefix. Must include the preceding '/'. default is just '/' +#JENKINS_PREFIX=/ + +## set the http listening port. -1 to disable, Default is 8080 +#JENKINS_HTTP_PORT=8080 + +## set the http listening address. Default is all interfaces +#JENKINS_HTTP_LISTENING_ADDRESS="localhost" + +## set the https listening port. -1 to disable, Default is disabled +#JENKINS_HTTPS_PORT=8080 + +## set the https listening address. Default is all interfaces +#JENKINS_HTTPS_LISTENING_ADDRESS="localhost" + +## the location of the SSL KeyStore file. Default is ./winstone.ks +#JENKINS_HTTPS_KEYSTORE="" + +## the password for the SSL KeyStore file. Default is null +#JENKINS_HTTPS_KEYSTORE_PASSWORD="" + +## the SSL KeyManagerFactory type (eg SunX509, IbmX509). Default is SunX509 +#JENKINS_HTTPS_KEY_MANAGER="SunX509" + +## Default home of jenkins stuffs +#JENKINS_HOME=/var/lib/jenkins + +## Default location to log +#JENKINS_LOG_DIR=/var/log/jenkins.log + +## set directory for multiple webapps to be deployed from +#JENKINS_WEBAPPSDIR=/var/lib/jenkins/apps/ + +## set document root folder +#JENKINS_WEBROOT=/var/lib/jenkins/webroot + +## any additionally flags available, see `jenkins --help` +#OPT_ARGS="" diff --git a/system/jenkins/files/jenkinsd.sh b/system/jenkins/files/jenkinsd.sh new file mode 100644 index 0000000000000..f10ed4f9abaf1 --- /dev/null +++ b/system/jenkins/files/jenkinsd.sh @@ -0,0 +1,119 @@ +#!/bin/sh +# Copyright 2008,2009 Vincent Batts, Birmingham, AL, USA +# Copyright 2010,2011 Vincent Batts, Vienna, VA, USA +# vbatts@hashbangbash.com, http://hashbangbash.com/ +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +JAVA=$(which java) +JENKINS="/usr/share/jenkins/jenkins.war" +JENKINS_USER="jenkins" +JENKINS_HTTP_PORT="8080" +JENKINS_LOG_FILE="/var/log/jenkins/jenkins.log" +JENKINS_CONSOLELOG_FILE="/var/log/jenkins/jenkins_console.log" +JENKINS_PID_DIR="/var/run/jenkins/" +JENKINS_PID_FILE="$JENKINS_PID_DIR/jenkins.pid" +JENKINS_WEBAPPSDIR="/var/lib/jenkins/apps/" +JENKINS_WEBROOT="/var/lib/jenkins/webroot/" +JENKINS_HOME="/var/lib/jenkins" +OPT_ARGS="" + +# Override some of the above settings, if defined in jenkins.conf +if [ -f /etc/jenkins/jenkins.conf ] ; then + . /etc/jenkins/jenkins.conf +fi + +export JENKINS_HOME + +PREV_PID=$( pgrep -f "$JENKINS" ) +if [ ! "$PREV_PID" = "" ] ; then + echo $PREV_PID still running + exit 1 +fi + +if [ "$JENKINS_PREFIX" != "" ] ; then + JENKINS_PREFIX_ARG="--prefix=$JENKINS_PREFIX" +fi + +if [ "$JENKINS_HTTP_PORT" != "" ] ; then + JENKINS_HTTP_PORT_ARG="--httpPort=$JENKINS_HTTP_PORT" +fi + +if [ "$JENKINS_HTTP_LISTENING_ADDRESS" != "" ] ; then + JENKINS_HTTP_LISTENING_ADDRESS_ARG="--httpListenAddress=$JENKINS_HTTP_LISTENING_ADDRESS" +fi + +if [ "$JENKINS_HTTPS_PORT" != "" ] ; then + JENKINS_HTTPS_PORT_ARG="--httpsPort=$JENKINS_HTTPS_PORT" +fi + +if [ "$JENKINS_HTTPS_LISTENING_ADDRESS" != "" ] ; then + JENKINS_HTTPS_LISTENING_ADDRESS_ARG="--httpsListenAddress=$JENKINS_HTTPS_LISTENING_ADDRESS" +fi + +if [ "$JENKINS_HTTPS_KEYSTORE" != "" ] ; then + JENKINS_HTTPS_KEYSTORE_ARG="--httpsKeyStore=$JENKINS_HTTPS_KEYSTORE" +fi + +if [ "$JENKINS_HTTPS_KEYSTORE_PASSWORD" != "" ] ; then + JENKINS_HTTPS_KEYSTORE_PASSWORD_ARG="--httpsKeyStorePassword=$JENKINS_HTTPS_KEYSTORE_PASSWORD" +fi + +if [ "$JENKINS_HTTPS_KEY_MANAGER" != "" ] ; then + JENKINS_HTTPS_KEY_MANAGER_ARG="--httpsKeyManagerType=$JENKINS_HTTPS_KEY_MANAGER" +fi + +if [ "$JENKINS_LOG_FILE" != "" ] ; then + JENKINS_LOG_FILE_ARG="--logfile=$JENKINS_LOG_FILE" +fi + +if [ "$JENKINS_WEBAPPSDIR" != "" ] ; then + JENKINS_WEBAPPSDIR_ARG="--webapssDir=$JENKINS_WEBAPPSDIR" +fi + +if [ "$JENKINS_WEBROOT" != "" ] ; then + JENKINS_WEBROOT_ARG="--webroot=$JENKINS_WEBROOT" +fi + +mkdir -p $JENKINS_PID_DIR +chown $JENKINS_USER $JENKINS_PID_DIR + +su - $JENKINS_USER -c " \ + JENKINS_HOME=$JENKINS_HOME \ + exec setsid \ + $JAVA -jar $JENKINS \ + $JENKINS_HTTP_PORT_ARG \ + $JENKINS_HTTP_LISTENING_ADDRESS_ARG \ + $JENKINS_HTTPS_PORT_ARG \ + $JENKINS_PREFIX_ARG \ + $JENKINS_HTTPS_LISTENING_ADDRESS_ARG \ + $JENKINS_HTTPS_KEYSTORE_ARG \ + $JENKINS_HTTPS_KEYSTORE_PASSWORD_ARG \ + $JENKINS_HTTPS_KEY_MANAGER_ARG \ + $JENKINS_LOG_FILE_ARG \ + $JENKINS_WEBAPPSDIR_ARG \ + $JENKINS_WEBROOT_ARG \ + $OPT_ARGS \ + </dev/null >> $JENKINS_CONSOLELOG_FILE 2>&1 & + + echo \$! > $JENKINS_PID_FILE + disown \$! + + " + diff --git a/system/jenkins/files/logrotate.jenkins b/system/jenkins/files/logrotate.jenkins new file mode 100644 index 0000000000000..f6b40db07baf2 --- /dev/null +++ b/system/jenkins/files/logrotate.jenkins @@ -0,0 +1,13 @@ +/var/log/jenkins/jenkins.log /var/log/jenkins/jenkins_console.log { + compress + dateext + maxage 365 + rotate 99 + size=+4096k + notifempty + missingok + create 644 + postrotate + kill -s SIGALRM `cat /var/run/jenkins.pid` + endscript +} diff --git a/system/jenkins/files/rc.jenkins b/system/jenkins/files/rc.jenkins new file mode 100644 index 0000000000000..d13e3912aa205 --- /dev/null +++ b/system/jenkins/files/rc.jenkins @@ -0,0 +1,82 @@ +#!/bin/sh +# Copyright 2008,2009 Vincent Batts, Birmingham, AL, USA +# Copyright 2010,2011 Vincent Batts, Vienna, VA, USA +# vbatts@hashbangbash.com, http://hashbangbash.com/ +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +function getPid() { + pgrep -f 'java.*jenkins.war' +} +pid_file="/var/run/jenkins/jenkins.pid" +max_wait=8 + +# Define start and stop functions +jenkins_start() { + p=$(getPid) + if [ $p ]; then + echo "jenkins appears to already be running." + echo "on $p, check it first ..." + exit 1 + else + echo "Starting jenkins daemon..." + jenkinsd 2>/dev/null 1>&2 || exit 1 + fi +} + +jenkins_stop() { + echo -ne "Stopping jenkins daemon... " + kill $(cat $pid_file) 2>/dev/null >/dev/null + + p=$(getPid) + if [ ${p} -gt 1 ] 2>/dev/null ; then + echo "pid ${p}" + kill ${p} + else + echo "jenkins.war not found running" + fi +} + +# See how we were called and take appropriate action +case $1 in + start) + jenkins_start + ;; + stop) + jenkins_stop + ;; + restart) + jenkins_stop + i=0 + while [ $i -lt $max_wait ] ; do + if [ $(getPid) ] >/dev/null ; then + sleep 1 + else + break + fi + i=$[$i+1] + done + jenkins_start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 + ;; +esac + diff --git a/system/jenkins/jenkins.SlackBuild b/system/jenkins/jenkins.SlackBuild new file mode 100644 index 0000000000000..e29ddc7b43d77 --- /dev/null +++ b/system/jenkins/jenkins.SlackBuild @@ -0,0 +1,93 @@ +#!/bin/sh + +# Slackware build script for jenkins + +# Copyright 2008-2011 Giorgio Peron +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +PRGNAM=jenkins +VERSION=${VERSION:-1.421} +BUILD=${BUILD:-1} +TAG=${TAG:-_SBo} + +ARCH=noarch + +CWD=$(pwd) +TMP=${TMP:-/tmp/SBo} +PKG=$TMP/package-$PRGNAM +OUTPUT=${OUTPUT:-/tmp} + +bailout() { + printf "\nThis requires a \"jenkins\" user and group.\n" + printf "\tgroupadd -g 251 jenkins\n" + printf "\tuseradd -g 251 -u 251 -r -s /bin/bash -d /var/lib/jenkins jenkins\n\n" + exit 1 +} + +if ! getent group jenkins 2>/dev/null 1>/dev/null ; then + bailout +elif ! getent passwd jenkins 2>/dev/null 1>/dev/null ; then + bailout +fi + +set -e + +rm -rf $PKG +mkdir -p $PKG $OUTPUT +cd $PKG + +mkdir -p $PKG/usr/share/$PRGNAM +cp $CWD/$PRGNAM.war $PKG/usr/share/$PRGNAM/$PRGNAM.war + +mkdir -p $PKG/usr/bin +cat $CWD/files/jenkins.bin.sh > $PKG/usr/bin/jenkins +cat $CWD/files/jenkinsd.sh > $PKG/usr/bin/jenkinsd +chmod 0755 $PKG/usr/bin/* + +mkdir -p $PKG/etc/$PRGNAM +cp $CWD/files/$PRGNAM.conf $PKG/etc/$PRGNAM/$PRGNAM.conf.new + +mkdir -p $PKG/etc/logrotate.d +cp $CWD/files/logrotate.$PRGNAM $PKG/etc/logrotate.d/$PRGNAM.new + +mkdir -p $PKG/etc/rc.d +cp $CWD/files/rc.$PRGNAM $PKG/etc/rc.d/rc.$PRGNAM.new + +mkdir -p $PKG/var/lib/$PRGNAM +chown jenkins.jenkins $PKG/var/lib/jenkins + +mkdir -p $PKG/var/log/$PRGNAM +touch $PKG/var/log/jenkins/jenkins.log.new +touch $PKG/var/log/jenkins/jenkins_console.log.new +chown -R jenkins.jenkins $PKG/var/log/jenkins + +mkdir -p $PKG/var/run/jenkins +chown jenkins:jenkins $PKG/var/run/jenkins + +mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION +cat $CWD/README > $PKG/usr/doc/$PRGNAM-$VERSION/README +cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild + +mkdir -p $PKG/install +cat $CWD/slack-desc > $PKG/install/slack-desc +cat $CWD/doinst.sh > $PKG/install/doinst.sh + +cd $PKG +/sbin/makepkg -c n -l y $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz} diff --git a/system/jenkins/jenkins.info b/system/jenkins/jenkins.info new file mode 100644 index 0000000000000..f860ca0cdf771 --- /dev/null +++ b/system/jenkins/jenkins.info @@ -0,0 +1,10 @@ +PRGNAM="jenkins" +VERSION="1.421" +HOMEPAGE="http://jenkins-ci.org" +DOWNLOAD="http://ftp-nyc.osuosl.org/pub/jenkins/war/1.421/jenkins.war" +MD5SUM="cca7962041b280e233b5c680ed9a6c9c" +DOWNLOAD_x86_64="" +MD5SUM_x86_64="" +MAINTAINER="Giorgio Peron" +EMAIL="giorgio.peron@gmail.com" +APPROVED="rworkman" diff --git a/system/jenkins/slack-desc b/system/jenkins/slack-desc new file mode 100644 index 0000000000000..acad1a615e0aa --- /dev/null +++ b/system/jenkins/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. Line +# up the first '|' above the ':' following the base package name, and the '|' +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':' except on otherwise blank lines. + + |-----handy-ruler------------------------------------------------------| +jenkins: Jenkins CI (automated job monitor) +jenkins: +jenkins: Jenkins monitors executions of repeated jobs, such as building a +jenkins: software project or jobs run by cron. Among those things, current +jenkins: Jenkins focuses on the following two jobs: +jenkins: (o) Building/testing software projects continuously +jenkins: (o) Monitoring executions of externally-run jobs +jenkins: +jenkins: Homepage: http://jenkins-ci.org/ +jenkins: +jenkins: |