-#!/bin/sh
+#!/bin/bash
+
+function restart_jenkins() {
+ sudo systemctl restart jenkins
+ sleep 1
+ echo -n "Restarting jenkins"
+ until $(curl --output /dev/null --silent --head --fail http://localhost:8080/login); do
+ printf '.'
+ sleep 3
+ done
+ echo
+ sleep 1
+}
sed -i 's|archive\.ubuntu\.com|mirrors.ocf.berkeley.edu|g' /etc/apt/sources.list
+# Assume that the vagrant host is running a local Nexus proxy
echo "192.168.33.1 nexus-proxy" >> /etc/hosts
apt-get update
apt-get -y install git
-git config --global user.email "gary.i.wu@huawei.com"
-git config --global user.name "Gary Wu"
+git config --global user.email "jenkins@localhost"
+git config --global user.name "jenkins"
apt-get -y install curl openjdk-8-jdk maven unzip
# install Jenkins
su -l jenkins -c "/vagrant/jenkins-init-1.sh"
-sudo systemctl restart jenkins
-sleep 10
+restart_jenkins
su -l jenkins -c "/vagrant/jenkins-init-2.sh"
-sudo systemctl restart jenkins
-sleep 10
+restart_jenkins
su -l jenkins -c "/vagrant/jjb-init.sh"
git init
git add -A
-git commit -m 'Initial installation config'
+git commit -m 'Initial installation config' > /dev/null
mkdir -p ~/.m2
cp /vagrant/settings.xml ~/.m2
rsync -avP /vagrant/jenkins/ .
git add -A
-git commit -m 'Set up jenkins user'
+git commit -m 'Set up jenkins user' > /dev/null
cd ~jenkins
git add -A
-git commit -m 'Installed plugins, restarted Jenkins'
+git commit -m 'Installed plugins, restarted Jenkins' > /dev/null
mkdir -p ~/.config/jenkins_jobs
EOF
git add -A
-git commit -m 'Set up initial jobs'
+git commit -m 'Set up initial jobs' > /dev/null