Refactoring 07/5207/1
authorGary Wu <gary.i.wu@huawei.com>
Thu, 22 Jun 2017 20:29:06 +0000 (13:29 -0700)
committerGary Wu <gary.i.wu@huawei.com>
Thu, 22 Jun 2017 20:29:06 +0000 (13:29 -0700)
Change-Id: I6fdd372db4d8856853eb045033bd9dfbdcbea160
Signed-off-by: Gary Wu <gary.i.wu@huawei.com>
bootstrap/jenkins/vagrant/bootstrap.sh
bootstrap/jenkins/vagrant/jenkins-init-1.sh
bootstrap/jenkins/vagrant/jenkins-init-2.sh
bootstrap/jenkins/vagrant/jjb-init.sh

index f428cc1..7c7fe5e 100755 (executable)
@@ -1,7 +1,20 @@
-#!/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
 
 
@@ -15,8 +28,8 @@ EOF
 
 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
@@ -31,13 +44,11 @@ sudo usermod -aG docker 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"
 
index 776f2db..104f040 100755 (executable)
@@ -13,7 +13,7 @@ EOF
 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
@@ -22,5 +22,5 @@ rm -rf users/admin
 rsync -avP /vagrant/jenkins/ .
 
 git add -A
-git commit -m 'Set up jenkins user'
+git commit -m 'Set up jenkins user' > /dev/null
 
index eb0efe6..0c5dd99 100755 (executable)
@@ -11,5 +11,5 @@ java -jar jenkins-cli.jar -s http://localhost:8080/ -auth jenkins:jenkins instal
 java -jar jenkins-cli.jar -s http://localhost:8080/ -auth jenkins:jenkins install-plugin envinject
 
 git add -A
-git commit -m 'Install initial plugins'
+git commit -m 'Install initial plugins' > /dev/null
 
index a37168d..5f32dbb 100755 (executable)
@@ -2,7 +2,7 @@
 
 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
@@ -21,5 +21,5 @@ logs/
 EOF
 
 git add -A
-git commit -m 'Set up initial jobs'
+git commit -m 'Set up initial jobs' > /dev/null