One: Installation configuration subversion+toriessvn
1. Download and install Subversion as a version control server
2. Download and install the TORIESSVN Code Management client Tool
3. Create a blank folder on any disk svnrepository, right click, select TORIESSVN, select Create Repository here
4. Go to the folder and add the user name, password in the passwd file
5. In order to use subversion you need to start the Subversion service, as follows: CMD executes the following command
SC create Svnservice binpath= "D:\Program files\subversion\bin\svnserve.exe--service-r D:\SVNRepository" displayname= "Svnservice" depend= Tcpip start= Auto
If added successfully, the service can see the svnservice of services to
execute net start Subversion, The service is started successfully
6. You can now manage the code with subversion and TORIESSVN, the code is done with Intelijje, and the Gradle plugin is added as a deployment tool
Intelijje Two: Install tomcat locally, download the jar of Jenkins, put it under Tomcat's WebApps, launch Tomcat, and go to http://localhost:8080/jenkins/to access Jenkins.
Three: Install the virtual machine, the virtual machine installed Linux as a Web application server, Linux installed Tomcat as a Web container, Jenkin related configuration is as follows
Go to this page http://localhost:8080/jenkins/configure, configure SSH Remote Host
Note: Do not use root as the user name, you need to create a new user name on Linux, otherwise you cannot link successfully
Four: Create job, configure job, write deploy script configuration to Jekins
1. Configure the SVN address of the job
2. Configure the Deploy script for automatic deployment
3. Deploy script idea: Kill Tomcat process--back up the old war package--Copy the new war package to the WebApps directory--Restart Tomcat
Note: Using FTP to put the local war into the Linux server, the script is as follows
#解决console输入乱码
Export lang= "en_US. UTF-8 "
#build后的war包
warfile_path=users/crown/.jenkins/jobs/test002/workspace/wap/build/libs/
Warfile_name=mytest001.war
#虚拟机上的tomcat路径
Remote_path=/opt/tomcat7/webapps
#备份年月日
bak_dt= ' Date +%y%m%d%h%m%s '
#FTP_IP
ftp_ip=192.168.199.108
#FTP_PORT
Ftp_port=21
#FTP_USER
Ftp_user=qiaotl
#FTP_PWD
Ftp_pwd=qiaotl
#1. Kill the current application process
Tomcat_pids= ' ps-ef|grep tomcat |awk ' {print $} '
For Tomcat_pid in ${tomcat_pids}
Do
echo "Process ID is ${tomcat_pid}"
Kill-9 $tomcat _pid
echo "KILL process ${tomcat_pid} successfully. "
Done
#2. Backing up files
#2.1. Enter the catalogue
CD ${remote_path}
#2.2. Determine if the file exists, and if there is a backup
if [!-F "${warfile_name}"]; Then
echo "No file!"
Else
MV ${warfile_name} ${warfile_name}${bak_dt}
echo "Backup file successfully!"
Fi
echo "Get into FTP to get new file"
ftp-n<<!
Open ${ftp_ip} ${ftp_port}
User ${ftp_user} ${ftp_pwd}
Binary
Prompt
CD ${warfile_path}
Get ${warfile_name}
Close
Bye
!
echo "Get file successfully!"
#4. Start the app
Export java_home=/usr/mysoft/jdk1.6.0_45
sh/opt/tomcat7/bin/startup.sh > Qtl.txt
echo "Restarted successfully!"
Attention:
1. The java_home variable is loaded when you start Tomcat, otherwise the execution startup.sh is unsuccessful
2. After booting, add an echo command because the startup.sh command has output, and Jenkins returns exit-status!=0 for output, so the build job fails
Five: Build Job
VI: View Linux Server WebApp directory
Seven: Visit MyTest001