Install the docker

Update the yum!

yum update

The installation

yum -y install docker

Start and join boot boot

sudo systemctl start docker sudo systemctl enable docker

Check the Docker service status

systemctl status docker

Docker installs Jenkins containers

To install Jenkins, go here to get the version you need:Hub.docker.com/_/jenkins?t…

Docker pull Jenkins/Jenkins: LTS == [insert picture description here] (https://img-blog.csdnimg.cn/20200615175326278.png)Copy the code

If the download speed is slow, you can set up docker accelerated image

<1> Edit vi /etc/dock/daemon. json <2> Set up accelerated mirrors {"registry-mirrors": ["http://hub-mirror.c.163.com"]} <3> Restart docker sudo systemctl restart docker Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" And "journalctl -xe" for details. <4> CD /var/lib/docker rm -rf * <5> Restart docker <6> Download Jenkins docker pull Jenkins :2.60.3Copy the code

Create a Jenkins directory where the user mounts the Jenkins inside the container

mkdir -p /data/jenkins_home/

The directory permissions need to be changed because the owner of the /data/jenkins_home/ directory is user root when mapping local data volumes, and the UID of Jenkins user in the container is 1000.

chown -R 1000:1000 /data/jenkins_home/

Create a container

Docker run -d --name Jenkins -p 10001:8080 -p 505:50000 -v /data/jenkins_home:/var/jenkins_home Jenkins :2.60.3

--name defines the name of a container. If not specified, a random number string is automatically generated as a UUID -p 8040:8080 port mapping. My local 8080 is used. Therefore, an 8040 -p 50000:50000 port mapping -v /data/ jenkins_HOME :/var/jenkins_home binds a data volume. /data/jenkins_home is the local data volume created just nowCopy the code

Jenkins by browser

http://IP address: 10001

Query Jenkins’ initial password == Note that this address is == in the Docker container

The first way (docker container) : docker exec, / var/Jenkins cat jenkins_home/secrets/initialAdminPassword second way (local data in) : cat /data/jenkins_home/secrets/initialAdminPasswordCopy the code

Download the system recommended plug-ins == Wait patiently for download ==

Create a project

Note: After installing the plug-in, you need to restart it for the plug-in to take effect

== Ensure that the following plug-ins are correctly installed: role-based Authorization Strategy Remote SSH plug-in: SSH Plugin SSH file transfer to remote server: Publish Over SSH front-end vue project :nodejs ==

Configure the global environment (JDK Maven Nodejs git)

== It is recommended that the system automatically install the nodeJS plug-in. If you need to publish front-end projects, install the NodeJS plug-in. ==

Configuring the Remote Server

New task publishes the Spring Boot project to the remote server

Create a task

Configure general == Set the parameters based on your requirements

Source code management

Build configuration

Maven: send files or execute Commands over SSH: Execute shell script on remote host using SSH: Run the shell script of the remote server to stop the original service and start the new service. ==

Remote server script to deploy the Spring Boot project

#! SERVER_NAME= msbjsync. jar # directory where the jar is located The WAR package can be moved to the Tomcat webapps directory to run, using the JAR package, In Java - jar command execution JAR_NAME = msbjSync JAR_WORK_PATH = / usr/local/service/MSBJ/sync echo "query process id - > $SERVER_NAME" PID = ` ps - ef | "Grep" $SERVER_NAME | grep -v grep | awk '{print $2}' ` echo "get process ID: $PID" echo "for id in $PID do kill -9 $id echo "killed" $ID" done echo "End the process" #echo "copy the JAR package to the execution directory :cp Jar $JAR_WORK_PATH" #cp $JAR_PATH/$jar_name. jar $JAR_WORK_PATH #echo "Copy jar package complete" CD $JAR_WORK_PATH # change file permissions chmod 755 $JAR_NAME. # background jar jar nohup Java - $JAR_NAME jar. The jar & # PID = ` ps - ef | grep "$SERVER_NAME" | grep -v The grep | awk '{print $2}' ` # echo "new process ID: $PID" ps - ef | grep Java echo 'execution finished building'Copy the code

Perform a task

New task publishes vUE project to remote server

Build environment

build