-
Notifications
You must be signed in to change notification settings - Fork 2
/
jenkins-swarm-client-run
executable file
·66 lines (54 loc) · 1.97 KB
/
jenkins-swarm-client-run
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
#!/bin/bash
set -e
fail() {
echo -e "$@"
exit 1
}
run_swarm() {
local java=${JAVA?JAVA is required}
local swarm_jar=${JSWARM_JAR?JSWARM_JAR is required}
[[ -x $java ]] || (fail "${java} is not executable")
[[ -f $swarm_jar ]] || (fail "${swarm_jar} not accessible")
declare -a cmd
cmd=("$java")
if [[ -n $JAVA_ARGS ]]; then
declare -a java_args_tmp
IFS=" " read -r -a java_args_tmp <<< "$JAVA_ARGS"
cmd+=("${java_args_tmp[@]}")
fi
cmd+=(-jar "$JSWARM_JAR")
[[ -n $JSWARM_MODE ]] && cmd+=(-mode "$JSWARM_MODE")
[[ -n $JSWARM_EXECUTORS ]] && cmd+=(-executors "$JSWARM_EXECUTORS")
[[ -n $JSWARM_USERNAME ]] && cmd+=(-username "$JSWARM_USERNAME")
[[ -n $JSWARM_PASSWORD ]] && cmd+=(-passwordEnvVariable JSWARM_PASSWORD)
[[ -n $JSWARM_AGENT_NAME ]] && cmd+=(-name "$JSWARM_AGENT_NAME")
[[ -n $JSWARM_MASTER_URL ]] && cmd+=(-master "$JSWARM_MASTER_URL")
[[ -n $JSWARM_LABELS ]] && cmd+=(-labels "$JSWARM_LABELS")
[[ -n $JSWARM_FSROOT ]] && cmd+=(-fsroot "$JSWARM_FSROOT")
[[ $JSWARM_DISABLE_CLIENTS_UNIQUE_ID == true ]] \
&& cmd+=(-disableClientsUniqueId)
[[ $JSWARM_DISABLE_SSL_VERIFICATION == true ]] \
&& cmd+=(-disableSslVerification)
[[ $JSWARM_DELETE_EXISTING_CLIENTS == true ]] \
&& cmd+=(-deleteExistingClients)
[[ -n $JSWARM_DESCRIPTION ]] && cmd+=(-description "$JSWARM_DESCRIPTION")
[[ -n $JSWARM_TUNNEL ]] && cmd+=(-tunnel "$JSWARM_TUNNEL")
[[ -n $JSWARM_AUTO_DISCOVERY_ADDRESS ]] &&
cmd+=(-autoDiscoveryAddress "$JSWARM_AUTO_DISCOVERY_ADDRESS")
if [[ -n "$JSWARM_TOOL_LOCATIONS" ]]; then
for t in $JSWARM_TOOL_LOCATIONS; do
cmd+=(--toolLocation "$t")
done
fi
if [[ -n $JSWARM_OTHER_ARGS ]]; then
declare -a jswarm_other_args_tmp
IFS=" " read -r -a jswarm_other_args_tmp <<< "$JSWARM_OTHER_ARGS"
cmd+=("${jswarm_other_args_tmp[@]}")
fi
[[ ${#@} -gt 0 ]] && cmd+=("$@")
# display swarm cli invocation
set -x
"${cmd[@]}"
}
run_swarm "$@"
# vim: tabstop=2 shiftwidth=2 expandtab