svn+jenkins packages the idea project, uploads it to the server and deploys it with one click

The steps for installing svn and jenkins on the server can be searched by yourself. The following process is for the idea project to be packaged and uploaded to the server through svn+jenkins and deployed with one click.

Note: svn and jenkins are both on the same server

1. Idea project configuration

1. Install TortoiseSVN

Link: https://pan.baidu.com/s/1AK49keF85YXX1Y7t1eEJgg 
Extraction code: as2w

Notice! ! !

Be sure to check this, otherwise the svn.exe file will not be generated in the installation directory and you will not be able to proceed to the next step.

2. Configure svn

Enter svn://your IP address in the browser (usually the port number 3690 will be added). Open svn explorer.

3, placement idea

Find File--->Settings--->Subversion

Build a communication bridge with svn

 ​​​​​

 

 

 

Restart idea (I need it) and then you can see that the files turn red

4. Upload the project to svn 

Right click on the project

 

 

 Then wait for a while and check whether the upload is successful in the svn resource manager.

 This is half done. The java project can be uploaded to the server's svn warehouse, and then Jenkins is configured.

 2. Configure jenkins

 Open the server's Jenkins, click System Management, and configure three places

 1. Plug-in management

 Enter Publish Over ssh in the optional plugin

Mine is already installed so it is not shown here. If it is not installed, just click to download.

 2. Global tool configuration

 

3. System configuration

 

 

3. Deployment and operation

1. Create a new task

 

 2. Configure build content

 

 

 

 

Then just copy the script below

#!/bin/sh
#进入jar所在路径
cd /home/jenkinsbuild
#查看运行记录,并停止进程
BUILD_ID=DONTKILLME #后台执行
pid=$(ps -ef|grep jar包全称|grep -v grep | awk '{print $2}')
function stop(){
if [ -n "$pid" ]
  then
        echo "pid进程 :$pid"
        kill -9 $pid
 else
    echo "进程没有启动"
fi
}
stop
sleep 5s
#启动运行程序
/usr/local/java/jdk1.8.0_201/bin/java -jar /home/jenkinsbuild/jar包全称 > svn_jenkins.log &

 Then save it and you can build it immediately. From then on, the process steps of packaging svn+jenkins to the server for one-click deployment are complete.

Guess you like

Origin blog.csdn.net/weixin_53799443/article/details/132343895