1. Download Jenkins
Address: https://jenkins.io/index.html
I downloaded the 2.19.3 version of the War package:Jenkins.war
2. Install Jenkins
Copy Jenkins.war to the Tomcat WebApps folder, if Tomcat is started, the Jenkins project will automatically unzip the boot, if Tomcat is stopped, you need to start the Tomcat service, go to the Bin folder, and execute it in the Linux environment. Startup.sh can start the service, under Windows double-click Startup.bat.
Then, access address: http://192.168.17.155:8080/jenkins, specific IP for the machine you deployed IP, see the following interface, then congratulations, Jenkins started.
For security, Jenkins asks you to fill in the initial password, password in the prompt file, find the file, copy the password, fill in the text box below, click Continue. (If you see a password for the prompt under Windows, Tomcat's console will also be able to find this password in the log file for catalina.out, which looks at Tomcat under Linux.) )
Choose the installation method, select the first one, click, enter the following interface
After the various plug-ins are installed, start setting up account information and log in to Jenkins with this account later
Then go to the homepage
3. Installing plugins
The above default installed plugins are not enough
Click System Management, plug-in management, optional plugins, filter search box to find the following plugins:
Maven Integration Plugin
SSH Plugin
Deploy to Container Plugin
4. Create a new Build task
Find code management, if it is SVN management, please choose Subversion, fill in the project address and account information, if it is git, fill out the Git information
Build triggers, remove all tick marks, and trigger with a manual click
The above information prompts you to configure the MAVEN installation path, we can do so, by the way, configure the JDK path
MAVEN Build Command Configuration
Deployment Configuration
The tomcat user is configured within the Conf/tomcat-user.xml and the configuration is given below
<tomcat-users> <rolerolename= "Manager-gui" /> <rolerolename= "Manager-status" /> <rolerolename= "MANAGER-JMX" /> <rolerolename= "Manager-script"/> <rolerolename= "Admin-gui"/> <rolerolename= "Admin-script"/> <Userusername= "Tomcat"Password= "Tomcat"Roles= "Manager-gui,manager-status,manager-jmx,manager-script,admin-gui,admin-script"/></tomcat-users>
Save Configuration
5. Build
Click Navigation Jenkins--My views--click Study Project--Build now
If the interface card is found to be dead, it may be a JDK memory overflow that appears as follows
Set Tomcat's JDK parameters, add the following parameters to the Catalina.bat file, and the Linux system is the catalina.sh file
Java_opts= "-server-xx:permsize=256m-xx:maxpermsize=1024m-xms512m-xmx1024m-xx:maxnewsize=256m"
Restart Tomcat, click Build again, and in console output you can see the entire build process, which indicates that the entire build deployment was successful.
6. Attach the shell Footstep deployment method, more flexible (Jenkins and server must both be Linux machines)
The idea is to execute the remote script to close Tomcat and then execute the local script to copy the file to remote, then execute the remote script to start the Tomcat service. The above SCP command transfer file without password, you must configure the SSH key pair, configured as follows:
This assumes that host a (192.168.100.3) is used to obtain a file for Host B (192.168.100.4).
Execute the following command on host A to generate the pairing key:
SSH-KEYGEN-T RSA
When prompted to enter the default, the public key is stored in the user directory. The SSH directory, such as root, is stored in:
/root/.ssh/id_rsa.pub
Copy the Id_rsa.pub file from the. SSH directory to the ~/.ssh/directory in Host B and rename it to Authorized_keys.
Execute the command in host A and Host B to establish trust, as an example (assuming Host B's IP is: 192.168.100.4):
SCP ~/.ssh/id_rsa.pub 192.168.100.4:/root/.ssh/authorized_keys
Below you can use the SCP, SSH command does not need a password to get Host B files
SSH 192.168.100.4 Enter does not require a password.
Automating the deployment of Java MAVEN projects using Jekins (jdk1.7+tomcat7.0+jenkins2.19.3)