forked from lwhsu/jenkins-agent-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstartagent.sh
More file actions
executable file
·42 lines (34 loc) · 935 Bytes
/
Copy pathstartagent.sh
File metadata and controls
executable file
·42 lines (34 loc) · 935 Bytes
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
#! /bin/sh
export PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin"
cd /jenkins/jenkins-agent-scripts || exit 1
if [ -r agent.conf ]; then
. agent.conf
fi
for i in jenkins_url secret; do
eval v=\$$i
if [ -z "${v}" ]; then
echo "${i} is not defined" >&2
exit 1
fi
done
if [ -z "${agentname}" ]; then
agentname=`/bin/hostname`
fi
ipv6opt=""
if [ "${use_ipv6}" = "YES" ]; then
ipv6opt="-Djava.net.preferIPv6Addresses=true"
fi
if [ -n "${nice_increment}" ] && [ ${nice_increment} -ne 0 ]; then
NICE_CMD="/usr/bin/nice -n ${nice_increment}"
fi
while [ ! -f agent.dontstart ]
do
/bin/date
# mirror mode, update it if there's a timestamp change on the master
/usr/bin/fetch -m -o agent.jar "${jenkins_url}/jnlpJars/agent.jar"
${NICE_CMD} /usr/local/bin/java ${ipv6opt} \
-jar agent.jar \
-jnlpUrl "${jenkins_url}/computer/${agentname}/slave-agent.jnlp" \
-secret "${secret}"
/bin/sleep 30
done