jenkins节点重启脚本

远程重启jenkins节点脚本

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
NODE_CONFIG=nodes.ini
JENKINS_CLIENT_COMMAND=/opt/work/local/jenkins/jenkins-client/bin/client.sh
start_nodes() {
while read node
do
if [ -z "$node" ]; then
continue;
fi
echo "current node: $node";
start_remote_jenkins $node;
done < $NODE_CONFIG
}
start_remote_jenkins() {
remote_ip=$1
ssh $remote_ip 2>&1 << remote_command
sh $JENKINS_CLIENT_COMMAND;
exit;
remote_command
}
start_nodes

jenkins slave脚本

jenkins slave重启脚本

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
113
114
115
function file_source() {
if [ -f $1 ]; then
source $1;
fi
}
file_source /etc/profile
file_source ~/.profile
file_source ~/bash_profile
if test -z "${JAVA_HOME}"; then
echo "please config JAVA_HOME~"
exit 1;
fi
BIN_PARAM='start'
if [ $# -ge 1 ]; then
BIN_PARAM=$1
fi
JAVA_EXE=$JAVA_HOME/bin/java
BIN_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
SLAVE_CONFIG=$BIN_PATH/slave.conf
source $SLAVE_CONFIG
SLAVE_HOME=$(dirname $BIN_PATH)
LOG_FILE=$SLAVE_HOME/logs/jenkins_slave.log
SLAVE_PID_COMMAND="ps -ef | grep $SECRET_ID | grep -v grep | awk '{print \$2}'"
SLAVE_PID=$(eval $SLAVE_PID_COMMAND)
START_COMMAND="nohup $JAVA_EXE -jar ${BIN_PATH}/slave.jar -jnlpUrl http://${SERVER_HOST}:${SERVER_PORT}/computer/${SLAVE_NAME}/slave-agent.jnlp -secret $SECRET_ID 1>>$LOG_FILE 2>&1 &"
echo "========================================"
echo "java bin path: $JAVA_EXE"
echo "slave client home path: $SLAVE_HOME"
echo "slave client bin path: $BIN_PATH"
echo "load slave client conf: $SLAVE_CONFIG"
echo "========================================"
echo "jenkins connection params:"
echo " - server host: $SERVER_HOST"
echo " - server port: $SERVER_PORT"
echo " - slave name: $SLAVE_NAME"
echo " - secret id: $SECRET_ID"
echo "========================================"
function startup() {
echo "execute get process command: $SLAVE_PID_COMMAND"
if [ -n "$SLAVE_PID" ]; then
echo "process with $SECRET_ID has existed."
echo "jenkins slave client pid: $SLAVE_PID"
exit 0;
fi
echo "execute script shell: $START_COMMAND"
eval $START_COMMAND
if [ $? -ne 0 ]; then
echo "fail to startup the jenkins slave client."
exit 1;
fi
SLAVE_PID=$(eval $SLAVE_PID_COMMAND)
echo "the jenkins slave client process id: $SLAVE_PID"
return;
}
function shutdown() {
echo "execute get process command: $SLAVE_PID_COMMAND"
if [ -z "$SLAVE_PID" ]; then
echo "no process with $SECRET_ID"
exit 0;
fi
echo "killing process with pid: $SLAVE_PID"
kill -9 $SLAVE_PID
if [ $? -ne 0 ]; then
echo "fail to shutdown the jenkins slave client with pid: $SLAVE_PID"
exit 1;
fi
echo "the jenkins slave client has stoped."
return;
}
function bootstrap() {
if [ $BIN_PARAM == "start" ] || [ $BIN_PARAM == "startup" ]; then
echo "startup jenkins slave client..."
startup
exit 0;
elif [ $BIN_PARAM == "stop" ] || [ $BIN_PARAM == "shutdown" ]; then
echo "shutdown jenkins slave client..."
shutdown
exit 0;
else
echo "not support param: $1"
exit 1;
fi
}
bootstrap

node节点

1
2
3
4
5
var links = document.getElementsByClassName("model-link");
for (var i=0;i<links.length;i++)
{
console.log(links[i].innerText);
}
1
2
3
4
5
6
10.10.1.11
10.10.1.12
10.10.1.13
10.13.2.14
10.13.2.15
10.13.2.16
文章目录
  1. 远程重启jenkins节点脚本
  2. jenkins slave脚本
  3. node节点
|