Guide language:
Packaged deployment for the back-end programmer is a very common thing in daily work, have a plenty of manual local packaged deployment on pushed to the server, or pull a corresponding branch code on the server in packaged deployment, this process is not automatic, and on how to deploy the server all the repetitive work will take a lot of time. At this time, we can use Jenkins or similar automatic release deployment software to reduce the repetitive work, save time, and can have more time to do more creative things.
Deployment steps:
Premise:
JDK has been installed on the server. Maven has been installed on the server. 3.6.3 is installed. Jenkins has been installed on the server (2.249.3 installed in this article)Copy the code
The premise of this article is that Jenkins is already installed and you just need to configure and publish the Maven project. It is not complicated to install Jenkins. If you download Jenkins package from the official website and put it into Tomcat, you can run it after configuring account encryption.
Configuration:
1. Click Global Tool Configuration from the Running Jenkins web page
As shown in figure:
Then configure the Java, Git, and Maven paths
2. Install the Maven Integration Plugin, Publish Over SSH.
3. From Jenkins’ home page, go to System Administration > System Configuration and find Publish Over SSH. This plug-in is used to push the package to the remote server, fill in the server address, and login account secret and so on.
4. Now that the basic configuration is complete, go to New Task > Build a Maven project
5. Then start filling in the various configurations. During the parameterized build process, choose which branch to pull code from Git based on the configuration shown in the figure.
6. Source code management Here to write code git address and account secret, but also can add branch selection (after adding can be in the build, the drop-down box to choose which branch to use)
7. Fill in the poM file location and package command here, which is the package command of MVN
8. Archive configuration and Remote Deployment Configuration The archive configuration is to pack the package can be downloaded from the page, remote deployment configuration is to pack the package to the remote server deployment configuration, the server can select multiple, configure multiple will publish the deployment to multiple machines. The script for automatic deployment is written in Exec Command and executed after being pushed to the server to automatically deploy the project.
Release:
1. Click the project and select Build with Parameters
2. Select the branch and click to start building
3. View logs. SUCCESS is displayed