-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathjenkins-standalone.sh
executable file
·93 lines (83 loc) · 2.57 KB
/
jenkins-standalone.sh
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
#!/bin/bash
set -e
# $JENKINS_VERSION should be an LTS release
JENKINS_VERSION="1.580.2"
# List of Jenkins plugins, in the format "${PLUGIN_NAME}/${PLUGIN_VERSION}"
JENKINS_PLUGINS=(\
"credentials/1.18" \
"email-ext/2.39" \
"git/2.3.1" \
"git-client/1.12.0" \
"greenballs/1.14" \
"hipchat/0.1.8" \
"logstash/1.0.3" \
"metadata/1.1.0b" \
"mesos/0.5.0" \
"monitoring/1.54.0" \
"parameterized-trigger/2.25" \
"saferestart/0.3" \
"scm-api/0.2" \
"script-security/1.12" \
"ssh-credentials/1.10" \
"token-macro/1.10" \
)
JENKINS_WAR_MIRROR="http://mirrors.jenkins-ci.org/war-stable"
JENKINS_PLUGINS_MIRROR="http://updates.jenkins-ci.org"
JENKINS_PLUGINS_BASEURL="${JENKINS_PLUGINS_MIRROR}/download/plugins"
# Ensure we have an accessible wget
command -v wget > /dev/null
if [[ $? != 0 ]]; then
echo "Error: wget not found in \$PATH"
echo
exit 1
fi
# Accept ZooKeeper paths on the command line
if [[ ! $# > 3 ]]; then
echo "Usage: $0 -z zk://10.132.188.212:2181[, ... ]/mesos -r redis.example.com"
echo
exit 1
fi
while [[ $# > 1 ]]; do
key="$1"
shift
case $key in
-z|--zookeeper)
ZOOKEEPER_PATHS="$1"
shift
;;
-r|--redis-host)
REDIS_HOST="$1"
shift
;;
*)
echo "Unknown option: ${key}"
exit 1
;;
esac
done
# Jenkins WAR file
if [[ ! -f "jenkins.war" ]]; then
wget -nc "${JENKINS_WAR_MIRROR}/${JENKINS_VERSION}/jenkins.war"
fi
# Jenkins plugins
[[ ! -d "plugins" ]] && mkdir "plugins"
for plugin in ${JENKINS_PLUGINS[@]}; do
IFS='/' read -a plugin_info <<< "${plugin}"
plugin_path="${plugin_info[0]}/${plugin_info[1]}/${plugin_info[0]}.hpi"
wget -nc -P plugins "${JENKINS_PLUGINS_BASEURL}/${plugin_path}"
done
# Jenkins config files
sed -i "s!_MAGIC_ZOOKEEPER_PATHS!${ZOOKEEPER_PATHS}!" config.xml
sed -i "s!_MAGIC_REDIS_HOST!${REDIS_HOST}!" jenkins.plugins.logstash.LogstashInstallation.xml
sed -i "s!_MAGIC_JENKINS_URL!http://${HOST}:${PORT}!" jenkins.model.JenkinsLocationConfiguration.xml
# Start the master
export JENKINS_HOME="$(pwd)"
java -jar jenkins.war \
-Djava.awt.headless=true \
--webroot=war \
--httpPort=${PORT} \
--ajp13Port=-1 \
--httpListenAddress=0.0.0.0 \
--ajp13ListenAddress=127.0.0.1 \
--preferredClassLoader=java.net.URLClassLoader \
--logfile=../jenkins.log