| 1 | 1 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,69 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+ |
|
| 2 |
+# Echo commands, exit on error |
|
| 3 |
+set -o xtrace |
|
| 4 |
+set -o errexit |
|
| 5 |
+ |
|
| 6 |
+# Make sure only root can run our script |
|
| 7 |
+if [[ $EUID -ne 0 ]]; then |
|
| 8 |
+ echo "This script must be run as root" |
|
| 9 |
+ exit 1 |
|
| 10 |
+fi |
|
| 11 |
+ |
|
| 12 |
+# This directory |
|
| 13 |
+CUR_DIR=$(cd $(dirname "$0") && pwd) |
|
| 14 |
+ |
|
| 15 |
+# Install software |
|
| 16 |
+DEPS="jenkins" |
|
| 17 |
+apt-get install -y --force-yes $DEPS |
|
| 18 |
+ |
|
| 19 |
+# Install jenkins |
|
| 20 |
+if [ ! -e /var/lib/jenkins ]; then |
|
| 21 |
+ echo "Jenkins installation failed" |
|
| 22 |
+ exit 1 |
|
| 23 |
+fi |
|
| 24 |
+ |
|
| 25 |
+# Setup sudo |
|
| 26 |
+JENKINS_SUDO=/etc/sudoers.d/jenkins |
|
| 27 |
+cat > $JENKINS_SUDO <<EOF |
|
| 28 |
+jenkins ALL = NOPASSWD: ALL |
|
| 29 |
+EOF |
|
| 30 |
+chmod 440 $JENKINS_SUDO |
|
| 31 |
+ |
|
| 32 |
+# Setup .gitconfig |
|
| 33 |
+JENKINS_GITCONF=/var/lib/jenkins/hudson.plugins.git.GitSCM.xml |
|
| 34 |
+cat > $JENKINS_GITCONF <<EOF |
|
| 35 |
+<?xml version='1.0' encoding='UTF-8'?> |
|
| 36 |
+<hudson.plugins.git.GitSCM_-DescriptorImpl> |
|
| 37 |
+ <generation>4</generation> |
|
| 38 |
+ <globalConfigName>Jenkins</globalConfigName> |
|
| 39 |
+ <globalConfigEmail>jenkins@rcb.me</globalConfigEmail> |
|
| 40 |
+</hudson.plugins.git.GitSCM_-DescriptorImpl> |
|
| 41 |
+EOF |
|
| 42 |
+ |
|
| 43 |
+# Set ownership to jenkins |
|
| 44 |
+chown -R jenkins $CUR_DIR |
|
| 45 |
+ |
|
| 46 |
+# Set up jobs symlink |
|
| 47 |
+if [ ! -h /var/lib/jenkins/jobs ]; then |
|
| 48 |
+ echo "Installing jobs symlink" |
|
| 49 |
+ if [ -d /var/lib/jenkins/jobs ]; then |
|
| 50 |
+ mv /var/lib/jenkins/jobs /var/lib/jenkins/jobs.old |
|
| 51 |
+ fi |
|
| 52 |
+ ln -s $CUR_DIR/jobs /var/lib/jenkins/jobs |
|
| 53 |
+fi |
|
| 54 |
+ |
|
| 55 |
+# List of plugins |
|
| 56 |
+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 |
|
| 57 |
+ |
|
| 58 |
+# Configure plugins |
|
| 59 |
+for plugin in ${PLUGINS//,/ }; do
|
|
| 60 |
+ name=`basename $plugin` |
|
| 61 |
+ dest=/var/lib/jenkins/plugins/$name |
|
| 62 |
+ if [ ! -e $dest ]; then |
|
| 63 |
+ curl -L $plugin -o $dest |
|
| 64 |
+ fi |
|
| 65 |
+done |
|
| 66 |
+ |
|
| 67 |
+# Restart jenkins |
|
| 68 |
+restart jenkins |