-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathjenkins.install
executable file
·112 lines (100 loc) · 3.82 KB
/
jenkins.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
#
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
src="$1"
dir="$2"
version="$3"
ROLE=jenkins
ORIG=$(cd $(dirname $0); pwd)
. ${ORIG}/functions
#
# Jenkins
#
case $OS in
"CentOS"|"RedHatEnterpriseServer")
case "$CODENAME_MAJOR" in
6)
CODENAME_MAJOR_PACKAGES="rake sloccount puppet-lint"
;;
7)
# TODO [FL Mon Jul 21 15:05:31 2014] find puppet-lint and
# sloccount for RHEL/CentOS
CODENAME_MAJOR_PACKAGES="rubygem-rake"
;;
esac
# Add a way to specify a Jenkins version to install (especially the LTS version)
[ -n "$JENKINS_VERSION" ] && JENKINS_VERSION="-${JENKINS_VERSION}"
JENKINS_PACKAGES="jenkins${JENKINS_VERSION} puppet git python-pip rubygems rubygem-rake $CODENAME_MAJOR_PACKAGES"
;;
*)
JENKINS_PACKAGES="jenkins puppet git python-pip sloccount rubygems rake puppet-lint"
;;
esac
JENKINS_URL=https://updates.jenkins-ci.org/download/plugins
JENKINS_URL2=http://ftp.nluug.nl/programming/jenkins/plugins
JENKINS_PLUGINS="ssh-agent/1.4.1/ssh-agent.hpi \
gearman-plugin/0.1.1/gearman-plugin.hpi \
promoted-builds/2.17/promoted-builds.hpi \
git-client/1.9.0/git-client.hpi \
scm-api/0.2/scm-api.hpi \
parameterized-trigger/2.24/parameterized-trigger.hpi \
token-macro/1.10/token-macro.hpi \
multiple-scms/0.3/multiple-scms.hpi \
ansicolor/0.4.0/ansicolor.hpi \
git/2.2.1/git.hpi \
reverse-proxy-auth-plugin/1.4.0/reverse-proxy-auth-plugin.hpi"
JENKINS_CACHE=${JENKINS_CACHE:=${dir}/../../jenkins-plugins-cache}
update_repositories $dir
install_ib_if_needed $ORIG $dir
case "$(package_tool)" in
"apt")
[ -f "jenkins-ci.org.key" ] || wget -q http://pkg.jenkins-ci.org/debian-stable/jenkins-ci.org.key -O jenkins-ci.org.key
do_chroot $dir apt-key add - < jenkins-ci.org.key
cat > ${dir}/etc/apt/sources.list.d/jenkins.list <<EOF
deb http://pkg.jenkins-ci.org/debian-stable binary/
EOF
update_repositories $dir
;;
"yum")
wget -O $dir/etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
chroot $dir rpm --import http://pkg.jenkins-ci.org/redhat-stable/jenkins-ci.org.key
;;
*)
fatal_error "$package_tool isn't supported for $ROLE role"
;;
esac
add_epel_repository $DIST
install_packages $dir "$JENKINS_PACKAGES"
remove_epel_repository $DIST
#
# Jenkins Post Inst
#
mkdir -p ${dir}/var/lib/jenkins/plugins
do_chroot $dir chown jenkins /var/lib/jenkins /var/lib/jenkins/plugins
for plugin in ${JENKINS_PLUGINS}; do
plugin_name=$(basename ${plugin})
echo "Installing plugin ${plugin_name}"
if [ ! -r $JENKINS_CACHE/$plugin ]; then
mkdir -p $JENKINS_CACHE/$(dirname ${plugin})
wget -q -O - "${JENKINS_URL}/${plugin}" > $JENKINS_CACHE/$plugin || wget -q -O - "${JENKINS_URL2}/${plugin}" > $JENKINS_CACHE/$plugin
fi
cp $JENKINS_CACHE/$plugin ${dir}/var/lib/jenkins/plugins/${plugin_name}
done
#
# jjb
#
do_chroot ${dir} pip install jenkins-job-builder
mkdir -p ${dir}/etc/jenkins_jobs
# jenkins.install ends here