First, preface
As is known to all, Jenkins can implement project updates by default (via SVN, but our company uses git), and projects are released through (Maven plugin), but in this case under some containers (such as Tomcat), The JVM will report OutOfMemoryError PermGen space after several releases, because these containers will not release resources from the old Project memory permanent area after overwriting the old project, resulting in a system persistent memory overflow over time. To solve this problem, we can only resolve this issue by restarting the container after publishing. What can I do to get the container to restart automatically after the new project is released? During the restart process, we want the container to be processed after the job is safely completed (such as after the quartz job executes), the container restarts again, how to do? This article is to share with you is one of the convenient security methods.
Second, Jenkins installation and configuration
Jenkins is an open source software project designed to provide an open and easy-to-use software platform that makes continuous integration possible.
Installing the Jenkins stable version
sudo wget-o/etc/yum.repos.d/jenkins.repo Http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
sudo rpm--import Http://pkg.jenkins-ci.org/redhat-stable/jenkins-ci.org.key
sudo yum install Jenkins
Note: This method cannot download rpm, so use the following method
rpm:https://mirror.tuna.tsinghua.edu.cn/jenkins/redhat-stable/
Upload to the specified directory
Yum Localinstall jenkins-2.7.2-1.1.noarch.rpm
Add JDK path in Jenkins config file
Vim/etc/rc.d/init.d/jenkins
/usr/local/java/jre/bin/java
Open Iptables 8080 Filter
Start Jenkins
Systemctl Start Jenkins
Visit Jenkins
http://192.168.2.64:8080/
Get Password Login
/var/lib/jenkins/secrets/initialadminpassword
Installing the MAVEN Plugin
Third, install the Git plugin
On the server where Jenkins is installed, create a pair of RSA keys and configure
Ssh-keygen-t rsa-c "Jenkins"
# All the way to the return, default path and file name, no password
CD ~/.ssh
MV Id_rsa Id_rsa_tho
MV Id_rsa.pub Id_rsa_tho.pub
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/8B/00/wKioL1hBNu3QhcgSAAD-7MkJKzc213.png "title=" Git-ssh.png "alt=" Wkiol1hbnu3qhcgsaad-7mkjkzc213.png "/>
Choose Add New credential, Username:git, private key Enter Directly, enter the contents of the Id_rsa_tho you just created, note that this is the private key, and that you want to copy the annotations.
Then under Gitlab Project, click on the right Configuration menu, deploy Keys, create a key with the content of the id_rsa_tho.pub you just created, name Readonly key for Jenkins, if there are multiple items that require this private Key, you can enable this key under deploy keys for each project.
So the two servers, git and Jenkins, establish a trust relationship.
Iv. Installing the Publish over SSH plugin
Installation steps:
System management → management plugin → optional plugin →artifact uploaders→publish over SSH
System settings (all advanced all expand)
Public configuration:
Passphrase: Password (Key's password if you set it up)
Path to Key:key file (private key)
Key: Copy the private key into this box
Disable exec: Disable Run command
Private configuration:
SSH Server Name: The name of the identity (whatever you take)
Hostname: Host name or IP address that requires SSH connection (recommended IP)
Username: User Name
Remote directory: Remotes
Use password authentication, or used a different key: The public configuration can be replaced (the thing that expands is public configuration is selected, this is good extensibility)
Advanced for private configuration:
Port: Ports (Default 22)
Timeout (ms): Timeout time (ms) default
Disable exec: Disable Run command
Test Configuration: Testing the connection
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/8B/00/wKioL1hBOd_wLyfjAADklZzAl8s700.png "title=" 1.png " alt= "Wkiol1hbod_wlyfjaadklzzal8s700.png"/>
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/8B/04/wKiom1hBOrKTrWmsAABRXUiA5K0931.png "title=" 2.png " alt= "Wkiom1hborktrwmsaabrxuia5k0931.png"/> access 192.168.2.77 server via SSH, the public key certificate must be imported to the client server, that is, 192.168.2.77, the command is as follows:
SCP id_rsa_tho.pub [Email Protected]:/root/.ssh/authorized_keys
This allows access between the two servers via SSH
V. Create a job
1. Source control, choose Git
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/8B/04/wKiom1hBPXqSJ9EPAAClodct5-Q560.png "title=" 3.png " alt= "Wkiom1hbpxqsj9epaaclodct5-q560.png"/>
2.maven Build, Build War Package
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/8B/04/wKiom1hBPc2gdXbTAAAv_EMfKgE424.png "title=" 4.png " alt= "Wkiom1hbpc2gdxbtaaav_emfkge424.png"/>
3. Select the server to publish for the specified war
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/8B/00/wKioL1hBPfWQxIEFAACdv-RnuL0286.png "style=" float: none; "title=" 5.png "alt=" Wkiol1hbpfwqxiefaacdv-rnul0286.png "/>
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/8B/04/wKiom1hBPfbi2AyAAAByFsQZhKs465.png "style=" float: none; "title=" 6.png "alt=" Wkiom1hbpfbi2ayaaabyfsqzhks465.png "/>
This article is from the technical Documentation blog, so be sure to keep this source http://jiangzm.blog.51cto.com/8314502/1878942
Jenkins+git+maven+shell implementation of Project one-click Release