Jenkins as a common CI/CD tool, the basic installation instructions are given below.
Docker, docker-compose installation
I have introduced how to install centos Docker installation click jump to the past
Jenkins docker – compose. Yml to write
In this case, Jenkins directly deployed the stand-alone version. If the memory is insufficient later, Jenkins Docker can be specified to use memory
Version: '3.1' services: Jenkins: image: Jenkins/Jenkins: Centos7 Container_name: Jenkins Networks: huzhihui: Ipv4_address: 172.20.20.1 volumes: - ./jenkins_home:/var/jenkins_home - /var/run/docker.sock:/var/run/docker.sock - /usr/bin/docker:/usr/bin/docker ports: - "8080:8080" environment: - "TZ=Asia/Shanghai" user: root networks: huzhihui: external: trueCopy the code
I have specified the network above. If you want to default the network, remove the network configuration
The shared directory allows hosts to perform operations on containers, and containers to perform operations on hosts. Hang volumes on hosts as required
Start Jenkins docker-compose. Yml and enter the password and other information as prompted to go to the home page
System configuration and global tool configuration
Configure common tools that can be used in subsequent processes
Global Tool configuration
The JDK MAVEN configuration
First copy the relevant JDK and MAVEN packages to shared folders, such as my shared folder
[root@localhost ext_soft]# pwd /usr/local/docker/jenkins/jenkins_home/ext_soft [root@localhost ext_soft]# ls Apache maven - 3.8.1 jdk1.8Copy the code
The JDK configuration
Git can be installed directly in the plug-in library, after the installation is shown below, do not configure yourself
Common tools Publish over SSH configuration
Remote Directory = Remote Directory = Remote Directory = Remote Directory = Remote Directory
Experience the release of the Springboot project JAR package
A simple example is given here, which can be extended as per individual needs. There are many plug-ins in the plug-in library that can provide additional help
New project
configuration
The Exec command sample
#This is where you shut down the old project processPROJECT_NAME = 'home - 1.0.0. Jar' PROCESS = ` ps - ef | grep $PROJECT_NAME | grep -v grep | grep -v PPID | awk '{print $2}' ` if [-n "$PROCESS" ]; then echo "kill PID=$PROCESS" for i in $PROCESS do echo "Kill the $PROJECT_NAME process [ $i ]" kill -9 $i done fi
#Switch to the directory to delete the previously running filesCD /root/home rm -rf /root/run/home-1.0.0.jar#Copy the transferred file to the run folderJar /root/run/home-1.0.0.jar CD /root/run#Maybe some of the machine configuration Java commands don't work, reread the configurationSource /etc/profile nohup java-jar home-1.0.0.jar --server.port=9000 >> nohup.log 2> &1&Copy the code