From 43acae4aa51ab66d522d83568a7e9271be7e65f7 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Tue, 8 Nov 2011 14:23:56 -0800 Subject: [PATCH] add initial build_jenkins script --- tools/jenkins/build_jenkins.sh | 69 ++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100755 tools/jenkins/build_jenkins.sh diff --git a/tools/jenkins/build_jenkins.sh b/tools/jenkins/build_jenkins.sh new file mode 100755 index 0000000..a20872d --- /dev/null +++ b/tools/jenkins/build_jenkins.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +# Echo commands, exit on error +set -o xtrace +set -o errexit + +# Make sure only root can run our script +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root" + exit 1 +fi + +# This directory +CUR_DIR=$(cd $(dirname "$0") && pwd) + +# Install software +DEPS="jenkins" +apt-get install -y --force-yes $DEPS + +# Install jenkins +if [ ! -e /var/lib/jenkins ]; then + echo "Jenkins installation failed" + exit 1 +fi + +# Setup sudo +JENKINS_SUDO=/etc/sudoers.d/jenkins +cat > $JENKINS_SUDO < $JENKINS_GITCONF < + + 4 + Jenkins + jenkins@rcb.me + +EOF + +# Set ownership to jenkins +chown -R jenkins $CUR_DIR + +# Set up jobs symlink +if [ ! -h /var/lib/jenkins/jobs ]; then + echo "Installing jobs symlink" + if [ -d /var/lib/jenkins/jobs ]; then + mv /var/lib/jenkins/jobs /var/lib/jenkins/jobs.old + fi + ln -s $CUR_DIR/jobs /var/lib/jenkins/jobs +fi + +# List of plugins +PLUGINS=http://hudson-ci.org/downloads/plugins/build-timeout/1.6/build-timeout.hpi,http://mirrors.jenkins-ci.org/plugins/git/1.1.12/git.hpi,http://hudson-ci.org/downloads/plugins/global-build-stats/1.2/global-build-stats.hpi,http://hudson-ci.org/downloads/plugins/greenballs/1.10/greenballs.hpi,http://download.hudson-labs.org/plugins/console-column-plugin/1.0/console-column-plugin.hpi + +# Configure plugins +for plugin in ${PLUGINS//,/ }; do + name=`basename $plugin` + dest=/var/lib/jenkins/plugins/$name + if [ ! -e $dest ]; then + curl -L $plugin -o $dest + fi +done + +# Restart jenkins +restart jenkins