Deploy Jenkins to a remote (Linux Server) and jenkinslinux
Next, the last time we said that we only implemented Local Automatic deployment. This is only applicable when the development environment and deployment environment are on the same machine. However, we usually need to deploy the project to a remote Linux server, so the main content of this section is:
1. Deploy a Web project in the development environment to a remote Linux server;
2. Automatic Backup;
Prepare the environment:
Local development, installation of virtual machines, installation of Linux servers on virtual machines
Procedure:
1. Install the plug-in. log on to the Jenkins background and choose System Management> Manage plug-in. In the optional plug-in, select Publish Over SSH to install the plug-in;
2. After installation, configure this option and find it in system management, for example:
Here, I will only talk about the main configuration items, such as SSH Server Name and Server Name. Just give them a Name. Hostname, Server IP address, Username, and remote Server account. Here I use root; remote Directory, access path, "/" root path.
For other options, see http://blog.csdn.net/wangmuming/article/details/22925895.
3. You do not need to create a new project this time. Make a copy of the project created above and modify it on this basis,
4. You do not need to change the above parameters. You only need to modify "post-build operations" and delete the method of deploying the war package (Deploy war/ear to a container, after adding the plug-in just now (Send build artifacts over SSH), the configuration is shown in the figure below:
Note: Remote directory, which is best configured as an absolute path, mainly to temporarily place the project, which can be seen in step 1;
5. Add deploy. sh script, the bin directory of the newly downloaded tomcat does not have this file, just create a new one, the content is as follows, adjust according to your actual situation, are some common shell commands:
#!/bin/shexport JAVA_HOME=/usr/java/jdk1.7.0_75kill -9 $(ps -aef | grep tomcat/conf | grep -v grep | awk '{print $2}')cd /app/programs/tomcat_test1/webappsmv ROOT.war ROOT_`date +%Y%m%d%H%M%S`.war.bak#rm -rf ROOTmv /app/programs/temp/mvcDemo3*-SNAPSHOT.war ROOT.warcd /app/programs/tomcat_test1/bin./startup.sh
6. After the above configuration, access the test and run it successfully.
Summary: Up to now, all configurations for automatic deployment to local and remote have been completed. These two documents mainly focus on Operation implementation and memo. Some details are not described. If you need them, you can study them in depth and discuss them one by one...