1. Deploy the project in jenkins
Make sure the project is running properly
1. Enter jenkins
2.New
3. Build execution script
There must be two folders, jar and project.
If not, add the following sentence to the script below
mkdir -p ${projectJar}
#!/bin/sh jarPath=/usr/java/jar projectJar=/usr/java/project echo "============Delete old jar=============" rm -rf ${projectJar}/demo.jar echo "======Copy the new jar to the running directory=======" cp ${jarPath}/demo.jar ${projectJar}/demo.jar echo "====================Close the jar process=====================" l=`ps -ef|grep -v grep|grep demo|awk '{print $2}'` kill -9 $l echo "================sleep 10s=========================" for i in {1..10} do echo $i"s" sleep 1s done export BUILD_ID=DontKillMe echo "====================Start jar=====================" nohup java -jar ${projectJar}/demo.jar & amp;
Apply Script Save
4. Execution
This is implemented immediately
Started successfully
5. Configure a new port number
Re-edit
Directly enter the address and port number in the address bar of the browser and do not make a mistake (the jar package name must also be checked)
6. Chinese plug-in
Search locale
2. Using jenkins 2
1. Install git
(1)Delete git
yum -y remove git
(2) Configure dependent environment
yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
(3)Installation
(This can also be used if the download address has resources)
wget https://github.com/git/git/archive/v2.9.3.tar.gz
(4)Unzip
tar -zxvf v2.9.3.tar.gz
(5) Enter and compile under git-2.9.3
make prefix=/usr/java/git all
Install
make prefix=/usr/java/git install
(6) Configure environment variables
vim /etc/profile
export GIT_HOME=/usr/java/git
export PATH=$GIT_HOME/bin:$PATH
(7) Make the configuration effective
source /etc/profile
(8)View version number
2. Install maven
(1) Download and unzip
Unzip to the specified file and download it from the official website
(2) Configure environment variables
export MAVEN_HOME=/usr/java/maven/apache-maven-3.8.8
export PATH=$MAVEN_HOME/bin:$PATH
Validate the file source /etc/profile
View version number
mvn -v
Configuration mirror
Find a mirror and put the image in it
alimaven
central
aliyun maven
http://maven.aliyun.com/nexus/content/repositories/central/
(3) Install the necessary maven plug-ins
mvn help:system
Set security configuration
Change these two to this
Install plugin
Global configuration
Using git in Idea
Install plugin
(4) Configure maven information
Where is the settings.xml corresponding to maven?
(5)Configure jdk
(6) Configure git
(7)maven installation
3. Build a maven project
1. Create a maven project
2. Create a warehouse
Code cloud warehouse account password
Configured credential information
3. Trigger time
Build every five minutes
4. Execute script
BUILD_ID=DONTKILLME echo "Deployed directory and project name" sh /usr/java/test/build.sh echo "success"
5. Do not package this class
clean package -U -Dmaven.test.skip=true
6. Set script file
#!/bin/bash echo "Deployed directory and project name" DIR="/usr/java/project" projectName="demo" echo "Application server to be deployed" server_ips="192.168.158.129" #All parameter lists for server_ip in ${server_ips[@]} do echo "Perform backup operation" mkdir -p $DIR/backup/${projectName} if [ -f "$DIR/${projectName}/${projectName}.jar" ];then mv $DIR/${projectName}/${projectName}.jar $DIR/backup/${projectName}/${projectName}-`date " + %Y%m%d_%H%M%S"` .jar fi echo "Copy the jar package to the directory of the target server" cp ${WORKSPACE}/target/*.jar $DIR/${projectName}/${projectName}.jar echo "Target server:$DIR/${projectName}/${projectName}.jar" echo "Connect for publishing operation" #mv /usr/java/test/demo.jar $DIR/backup/${projectName}/${projectName}.jar echo "Start closing jar" l=`ps -ef|grep demo.jar|grep -v grep|awk '{print $2}'` for i in $l do kill -9 $i done sleep 5s echo "start jar" nohup java -jar $DIR/${projectName}/${projectName}.jar --server.port=9999 > release_out.log 2> & amp;1 & amp;start_ok=false done
Run directly
He will get an error: Unable to obtain
Just delete the configured image.
After deleting
You will download a lot of things because it is the first time to run the spring boot project and you need a lot of things.