fd0caf5c63256117b949f945b7e21168cde01b83
[integration.git] / bootstrap / jenkins / vagrant / bootstrap.sh
1 #!/bin/bash
2 #
3 # Copyright 2017 Huawei Technologies Co., Ltd.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11
12 function restart_jenkins() {
13     sudo systemctl restart jenkins
14     sleep 1
15     echo -n "Restarting jenkins"
16     until $(curl --output /dev/null --silent --head --fail http://localhost:8080/login); do
17         printf '.'
18         sleep 3
19     done
20     echo
21     sleep 1
22 }
23
24 sed -i 's|archive\.ubuntu\.com|mirrors.ocf.berkeley.edu|g' /etc/apt/sources.list
25
26 # Assume that the vagrant host is running a local Nexus proxy
27 echo "192.168.33.1 nexus-proxy" >> /etc/hosts
28
29
30 cat >> /etc/inputrc <<EOF
31 set show-all-if-ambiguous on
32 set show-all-if-unmodified on
33 set match-hidden-files off
34 set mark-symlinked-directories on
35 EOF
36
37
38 apt-get update
39 apt-get -y install git
40 git config --global user.email "jenkins@localhost"
41 git config --global user.name "jenkins"
42 apt-get -y install curl openjdk-8-jdk maven unzip
43
44 # install Jenkins
45 wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
46 sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
47 apt-get update
48 apt-get -y install jenkins jenkins-job-builder python-pip
49
50 apt-get -y install docker.io
51 sudo usermod -aG docker ubuntu
52 sudo usermod -aG docker jenkins
53
54 su -l jenkins -c "/vagrant/jenkins-init-1.sh"
55
56 restart_jenkins
57
58 su -l jenkins -c "/vagrant/jenkins-init-2.sh"
59
60 restart_jenkins
61
62 su -l jenkins -c "/vagrant/jjb-init.sh"
63