blob: 25c6a45f6d12f5200bb878f96aca8f17b021eea8 [file] [log] [blame]
Gary Wu39a2f2f2017-11-10 13:38:28 -08001#!/bin/bash -x
Gary Wu5cccfa92017-08-02 12:03:10 -07002#
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#
Gary Wub2076ff2017-06-22 13:29:06 -070011
12function 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}
Gary Wu213a8352017-06-16 13:44:28 -070023
24sed -i 's|archive\.ubuntu\.com|mirrors.ocf.berkeley.edu|g' /etc/apt/sources.list
25
Gary Wub2076ff2017-06-22 13:29:06 -070026# Assume that the vagrant host is running a local Nexus proxy
Gary Wu213a8352017-06-16 13:44:28 -070027echo "192.168.33.1 nexus-proxy" >> /etc/hosts
28
29
30cat >> /etc/inputrc <<EOF
31set show-all-if-ambiguous on
32set show-all-if-unmodified on
33set match-hidden-files off
34set mark-symlinked-directories on
35EOF
36
37
38apt-get update
39apt-get -y install git
Gary Wub2076ff2017-06-22 13:29:06 -070040git config --global user.email "jenkins@localhost"
41git config --global user.name "jenkins"
Gary Wu39a2f2f2017-11-10 13:38:28 -080042apt-get -y install curl openjdk-8-jdk-headless maven unzip python-pip
Gary Wu213a8352017-06-16 13:44:28 -070043
44# install Jenkins
45wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
46sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
47apt-get update
Gary Wu39a2f2f2017-11-10 13:38:28 -080048apt-get -y install jenkins
Gary Wu213a8352017-06-16 13:44:28 -070049
Gary Wu39a2f2f2017-11-10 13:38:28 -080050# install docker
Gary Wu213a8352017-06-16 13:44:28 -070051apt-get -y install docker.io
Gary Wu213a8352017-06-16 13:44:28 -070052sudo usermod -aG docker jenkins
53
54su -l jenkins -c "/vagrant/jenkins-init-1.sh"
55
Gary Wub2076ff2017-06-22 13:29:06 -070056restart_jenkins
Gary Wu213a8352017-06-16 13:44:28 -070057
58su -l jenkins -c "/vagrant/jenkins-init-2.sh"
59
Gary Wub2076ff2017-06-22 13:29:06 -070060restart_jenkins
Gary Wu213a8352017-06-16 13:44:28 -070061
62su -l jenkins -c "/vagrant/jjb-init.sh"
63