CI/CD Operation Manual in traditional Cloud Environment (7) implementation of distributed jenkins with slave nodes
Operate on jenkins-slave
Cd / usr/local/src
Tar xvf jdk-7u79-linux-x64.tar.gz
Ln-sv / usr/local/src/jdk1.7.0_79 / usr/local/jdk
Vim / etc/profile
Export JAVA_HOME=/usr/local/jdk
Export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
Export CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar
Source / etc/profile & & java-version
Yum-y install git
Ssh-keygen
Put the public key on tomcat
Ssh-copy-id root@192.168.1.17
Ssh-copy-id root@192.168.1.18
Ntpdate ntp1.aliyun.com
Mkdir-p / data/jenkins/jdk/bin
Whereis java
Ln-sv / usr/bin/java / data/jenkins/jdk/bin/
Operate on gitlab:
Put the public key on gitlab
Click the projects---your projects---project1--- gear icon settings
-repository---Deploy Keys--- enter key value-click Write access allowed
Other projects also use the same key, but enable it manually in the Deploy Keys interface
Test on jenkins-slave
Git clone git@192.168.1.14:group1/project1.git
Configure the slave node on master
System management-node management-create a new node-name jenkins-slave1, fixed node-label and name are the same-remote working directory: / data/jenkins on slave
-usage: use this node whenever possible (both free style and pipeline projects give priority to automatic use of this node)
-Startup method: ip--- credential of launch agent agents via SSH---host:slave-add
-root (password) of kind:username with password---username:salve
-ip---Host Key Verification Strategy:non verifying verification strategy of descriptin:slave
Specify that the pipeline task is built using slave
Node ('jenkins-slave1') {stage (' git code') {echo 'git code' sh' rm-rf project1/' sh 'git clone git@192.168.1.14:group1/project1.git'} stage (' stop tomcat') {echo 'stop tomcat' sh' ssh 192.168.1.17 "/ etc/init.d/tomcat stop"'sh 'ssh 192.168.1.18 "/ etc/init.d/tomcat stop"} stage (' scp code') {echo 'scp code' sh' scp project1/* root@192.168.1.17:/data/tomcat/webapps/web01/' sh 'scp project1/* root@192.168.1.18:/data/tomcat/webapps/web01/'} stage (' stop tomcat') { Echo 'stop tomcat' sh' ssh 192.168.1.17 "/ etc/init.d/tomcat start"'sh 'ssh 192.168.1.18 "/ etc/init.d/tomcat start"'}}