-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathjenkins-slave.sh
47 lines (36 loc) · 1.4 KB
/
jenkins-slave.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
#!/bin/bash
# https://raw.githubusercontent.com/carlossg/jenkins-swarm-slave-docker/master/jenkins-slave.sh
# if `docker run` first argument start with `-` the user is passing jenkins swarm launcher arguments
if [[ $# -lt 1 ]] || [[ "$1" == "-"* ]]; then
# jenkins swarm slave
JAR=`ls -1 /tmp/swarm-client-*.jar | tail -n 1`
PARAMS=""
if [ ! -z "$JENKINS_USERNAME" ]; then
PARAMS="$PARAMS -username $JENKINS_USERNAME"
fi
if [ ! -z "$JENKINS_PASSWORD" ]; then
PARAMS="$PARAMS -password $JENKINS_PASSWORD"
fi
if [ ! -z "$JENKINS_MASTER" ]; then
PARAMS="$PARAMS -master $JENKINS_MASTER"
elif [ ! -z "$JENKINS_PORT_8080_TCP_ADDR" ]; then
PARAMS="$PARAMS -master http://$JENKINS_PORT_8080_TCP_ADDR:$JENKINS_PORT_8080_TCP_PORT"
else
echo "You must specify JENKINS_MASTER=http://your.jenkins.host"
exit 1
fi
if [ ! -z "$SLAVE_NAME" ]; then
PARAMS="$PARAMS -name $SLAVE_NAME"
fi
if [ ! -z "$SLAVE_EXECUTORS" ]; then
PARAMS="$PARAMS -executors $SLAVE_EXECUTORS"
fi
# if -master is not provided and using --link jenkins:jenkins
if [ ! -z "$SLAVE_PARAMS" ]; then
PARAMS="$PARAMS $SLAVE_PARAMS"
fi
echo Running java $JAVA_OPTS -jar $JAR -fsroot $HOME $PARAMS "$@"
exec java $JAVA_OPTS -jar $JAR -fsroot $HOME $PARAMS "$@"
fi
# As argument is not jenkins, assume user want to run his own process, for sample a `bash` shell to explore this image
exec "$@"