Main introduction: The installation and use of Windows Jenkins
I. Installation, configuration and use of Windows Jenkins
Deployment instructions: Jenkins server and application server on one machine. War Jenkins deployment: Jenkins. War (stable version) deployed under Windows-Tomcat
JDK greater than 1.5, tomcat7 above, maven3.0 above, otherwise there will be various problems.
Jenkins environment deployment process:
1. Install Jenkins under Tomcat
Enter the tomcat directory and add the tomcat user and permission conf/tomcat-users.xml
1. Download Jenkins war package: jenkins. IO /index.html 2. Install Jenkins. Copy Jenkins. War to tomcat webapps file and complete Jenkins installation.
WARNING [Finalizing set up] hudson.model.UpdateCenter.updateDefaultSite Upgrading Jenkins. Failed to update the default Update Site 'default'. Plugin upgrades may fail.
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
Copy the code
Problem resolution: Jenkins will display the Jenkins instance seems to have been offline Reason is the default is to upgrade the site link https://updates.jenkins.io/update-center.json is HTTPS mode of problem solving: Website at http://localhost:8085/jenkins/pluginManager/advanced and enter the bottom has a [upgrade site], changing the link by the HTTPS to HTTP, Updates. Jenkins. IO/update – cent… Once tomcat is restarted, it can be used normally.
Solve the problem of slow Jenkins download plug-in: original: updates. Jenkins. IO/update – cent… The original: updates. Jenkins. IO/update – cent…
http://mirror.esuni.jp/jenkins/updates/update-center.json
Copy the code
Replacement method: Go to Plugin Management -> Advanced (Tab), find the URL input box below the upgrade site, copy it to here, after setting up, need to restart Jenkins. Whether you started with a war package thrown in Tomcat, or in configuration mode, or in Docker, you need to restart. Initial password: http://localhost:8084/jenkins
My password is: 606 e96f75d0f40428f467d9d2d1963b3 click continue, jump to the following page
Select Install Suggested Plugins and wait for it to Install automatically
After the plugins are installed, set up your account information and use this account to log in to Jenkins
Full name: zhengja email: [email protected] Click: save and complete instance configuration:
You’d better change it to your own IP address. Then go to the home page:
Installation complete, start using Jenkins.
2. Change Jenkins workspace (optional, not required)
The Jenkins workspace is on drive C by default and it is not recommended to change the workspace with existing projects. Jenkins changes workspace
3. Jenkins configure plugins
(Jenkins plugin configuration /Jenkins plugin details. Md)
3.1 Manage Plugins
Jenkins starts automatically installing plugins by default (not said here) necessary plugins: Deploy to Contontainer Plugin Github, GitLab, Gerrit, and other system management repository Maven Intergration Plugin. GitHub Bran Soerce Plugin The Email Extension Plugin is an Extension for Email notification. It supports customizing Email content, triggering conditions, and Email recipients. It is more flexible than basic Email notification. Matrix Authorization Strategy Plugin: This Plugin provides matrix-based Authorization policies that support global and project-level configurationsCopy the code
4, Global Tool Configuration
Prerequisites: Maven, Tomcat, Git, and JDK must be installed on Windows
4.1 Configuring Maven Settings
4.2 configure the JDK
4.3 configure git
Git installation path (Linux :which Git, Windows: where Git)
4.4 configure maven
5. Configure System
5.1 Configuring the Jenkins URL
5.2 Configuring Global Mailbox Settings
5.2.2 Obtaining SMTP and Password(Authorization Code) :
Password is not the email or QQ id Password, but the authorization code of the email. [obtain QQ authorization code and SMTP server.md](other/obtain QQ authorization code and SMTP server.md)
5.2.3 Default Subject Default value:
Build notification:$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!
Copy the code
5.2.4 Default Content Default value:
<html>
<head>
<meta charset="UTF-8">
<title>${ENV, var="JOB_NAME"}- ${BUILD_NUMBER} time build log</title>
</head>
<body leftmargin="8" marginwidth="0" topmargin="8" marginheight="4"
offset="0">
<table width="95%" cellpadding="0" cellspacing="0" style="font-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-serif">
<tr>This email is automatically sent by the system, no need to reply!<br/>${PROJECT_NAME} Project build information</br>
<td><font color="#CC0000">${BUILD_STATUS}</font></td>
</tr>
<tr>
<td><br />
<b><font color="#0B610B">Build information</font></b>
<hr size="2" width="100%" align="center" /></td>
</tr>
<tr>
<td>
<ul>
<li>Project name: ${PROJECT_NAME}</li>
<li>Build number: the ${BUILD_NUMBER} build</li>
<li>${CAUSE}</li>
<li>Build status: ${BUILD_STATUS}</li>
<li>Build log:<a href="${BUILD_URL}console">${BUILD_URL}console</a></li>
<li>Build the Url:<a href="${BUILD_URL}">${BUILD_URL}</a></li>
<li>Working Directory:<a href="${PROJECT_URL}ws">${PROJECT_URL}ws</a></li>
<li>The Url of the project:<a href="${PROJECT_URL}">${PROJECT_URL}</a></li>
</ul>
<h4><font color="#0B610B">Failure case</font></h4>
<hr size="2" width="100%" />
$FAILED_TESTS<br/>
<h4><font color="#0B610B">Recently submitted (#$SVN_REVISION)</font></h4>
<hr size="2" width="100%" />
<ul>
${CHANGES_SINCE_LAST_SUCCESS, reverse=true, format="%c", changesFormat="<li>%d [%a] %m</li>"}
</ul>Detailed submission:<a href="${PROJECT_URL}changes">${PROJECT_URL}changes</a><br/>
</td>
</tr>
</table>
</body>
</html>
Copy the code
5.2.5 Successful Email Sending Effect: Used in the following test project
5.3 Configuring system FTP
Required plug-in -> Publish over FTP Generally back up files after deployment. Before using the files, you need to configure the FTP server in System Management > System Configuration.
There are few configurations to fill in. After filling in, click the Test Configuration button to Test whether your Configuration is correct.
Note: Remote Directory here refers to the path where you can work. For example, if I specify a path of /dir1, then I can only upload to subdirectories under this directory. If ONE day I want to upload to /dir2, sorry, you can’t access this path. If the configuration is correct, go to the project configuration page FTP. There is a project to configure the FTP instance below.
6, Create test project –> Tomcat + Jenkins on the same machine
Note: This is the local tomcat server and Jenkins on the same computer, if not the same server will report 403!
Initial implementation: Project configuration –> Automatically publish to tomcat server
Initial implementation: automatically pull down from Github –> Jenkins workspace –> package as WAR –> deploy to local Tomcat Webapps –> Automatically publish project. To create a task, enter a task name: sptingboot-test-github Select Freestyle Project
Later implementation 1: project configuration mailbox
Later implementation: automatically pull down from Github –> Jenkins workspace –> package into WAR –> deploy to local or remote Tomcat Webapps –> Automatically publish project –> Automatically send project build information to the specified mailbox.
Add Email configuration function: need Plugin –>Email Extension Plugin
Project Configuration Email:
Click “#27” –> to view build information
Effect of sending email successfully:
Later implementation 2: Configuring FTP
Publish over FTP -> Publish over FTP -> Publish over FTP
Remove prefix
Ii. Jenkins Configure nodes and use them
Windows_jenkins Machine environment: Tomcat + Jenkins + JDK Linux_127 Node environment: git, jdk1.8, Maven, tomcat8 Linux_127 node tool path:
Java: /usr/local/jdk1.8 maven: /usr/local/apache-3.6.2 git: /usr/local/git tomcat: / usr/local/apache tomcat — 8.5.46
1. Setup of Linux_127 node environment
Setting up a Linux node environment
2. Jenkins configure Linux_127 node tools
Configure the tool path for the Linux_127 node system Management –> Global Tool Configuration:
The JDK configuration:
The Git configuration:
Configure Maven:
3. Jenkins configure Linux_127
[Jenkins node slave configuration. Md](Jenkins node slave configuration /Jenkins node slave configuration. Md)
Jenkins deployed the project using the Linux_127 node
Project source: Github
Build process: Execute build -> pull the project from Github -> save it in the.jenkins2/workspace workspace of Linux_127 -> create war- > deploy to Tomcat on Linux_127 -> publish the project
Create a free-style task –> Task name: linux127-sptingboot-test-githuB2
Sh script -> to the project root directory:
#! /usr/bin/env bash
#Compile + deploy the project site
#Set the following parameters
#Project path, configure project path in Execute Shell,pwdYou can get the project path
# exportPROJ_PATH= The path of the Jenkins task on the deployment machine
# export PROJ_PATH=/root/.jenkins2
#Enter the full path of Tomcat in your environment
# exportTOMCAT_APP_PATH= Path of Tomcat on the deployment machine
# export TOMCAT_APP_PATH=/usr/local/ apache tomcat -- 8.5.46
## # base functionkillTomcat() { pid=`ps -ef|grep tomcat|grep java|awk '{print $2}'` echo "tomcat Id list :$pid" if [ "$pid" = "" ] then Echo "no tomcat pid alive" else kill -9 $pid fi # CD $TOMCAT_APP_PATH/bin #sh shutdown $PROJ_PATH/workspace/Linux127-springboot-test-github# mvn clean install
#Stop the tomcat
killTomcat
#Delete original project
#rm -rf $TOMCAT_APP_PATH/webapps/ROOT
#rm -f $TOMCAT_APP_PATH/webapps/ROOT.war
rm -rf $TOMCAT_APP_PATH/webapps/springboot-test-github
rm -f $TOMCAT_APP_PATH/webapps/springboot-test-github.war
#Copy the new project to TomcatCp $PROJ_PATH/workspace/Linux127 - springboot - test - making/target/springboot - test - making - 0.0.1 - the SNAPSHOT. War $TOMCAT_APP_PATH/webapps/ CD $TOMCAT_APP_PATH/webapps/ mv Springboot-test-github 0.0.1- snapshot.war springboot-test-github.war
#Start Tomcat
cd $TOMCAT_APP_PATH/
sh bin/startup.sh
Copy the code
Save execution “build” –> success! Effect: