Jenkins02: Jenkins+maven+svn integration

content

[TOC]

1. Install Maven and configure environment variables

          Download maven (windows download zip package, linux download tar.gz package), then configure environment variables

          Using maven in the project, you can get the jar package that the project depends on from the java central warehouse to complete the deployment of the project.

1.1 Linux configuration environment variable content

export MAVEN_HOME=/usr/local/apache-maven-3.5.3  -- 选择自己正确的版本号
export PATH=${PATH}:${MAVEN_HOME}/bin

After the configuration is complete, enter the source profile to make the environment variables take effect

Enter mvn -v in the terminal to see if maven is installed successfully

1.2 Contents of Windows configuration environment variables

添加环境变量
MAVEN_HOME=C:\Program Files\Maven\apache-maven-3.5.3
在path后追加环境变量:%MAVEN_HOME%\bin

Output mvn -v to check if the installation was successful
Check if maven is installed successfully

2. Configure the jdk and maven environment variables in Jenkins

2.1 Click System Management -> Global Tool Configuration in Jenkins to configure jdk and maven respectively

2.1.1 Configure jdk

Configure JDK

2.1.2 Configure maven

  1. Install the plugin Maven Integration plugin
  2. Configure maven in the global configuration tool

Configure MAVEN

3 Install and build svn

        installation documentation

4 Build the Jenkins integration project

  1. Build a maven project (need to install the Maven Integration plugin first )

entrance icon

  1. Configure source code management (svn)

Configure source code management

  1. Find Build under Pre Steps to configure

Build configuration under Pre steps

5. Project execution log output and interpretation

5.1 Display of key points in the log

5.1.1 Console output after project build is completed

Project build completed console output

5.1.2 Path of the generated jar package

The path of the generated jar package

5.1.3 If the console reports an error and the corresponding jar package cannot be found, the solution

        It means that the jar package cannot be downloaded in the central warehouse of maven, then you need to find the corresponding jar package for development and then put it on the console to report the error indication path.

5.2 Completed display of log output

由用户 admin 启动
构建中 在工作空间 C:\Program Files (x86)\Jenkins\workspace\Maven_SVN_Jenkins02 中
Updating https://172_16_0_13/svn/MySVN at revision '2018-05-09T19:13:45.498 +0800' --quiet
Using sole credentials admin/****** (SVN) in realm ‘<https://172_16_0_13:443> VisualSVN Server’
At revision 1

No changes for https://172_16_0_13/svn/MySVN since the previous build
No emails were triggered.
Parsing POMs
Established TCP socket on 52378
[JunitTest02] $ "C:\Program Files\Java\jdk1.8.0_144/bin/java" -cp "C:\Program Files (x86)\Jenkins\plugins\maven-plugin\WEB-INF\lib\maven35-agent-1.12-alpha-1.jar;C:\Program Files\Maven\apache-maven-3.5.3\boot\plexus-classworlds-2.5.2.jar;C:\Program Files\Maven\apache-maven-3.5.3/conf/logging" jenkins.maven3.agent.Maven35Main "C:\Program Files\Maven\apache-maven-3.5.3" "C:\Program Files (x86)\Jenkins\war\WEB-INF\lib\remoting-3.20.jar" "C:\Program Files (x86)\Jenkins\plugins\maven-plugin\WEB-INF\lib\maven35-interceptor-1.12-alpha-1.jar" "C:\Program Files (x86)\Jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-commons-1.12-alpha-1.jar" 52378
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven:  -B -f C:\Program Files (x86)\Jenkins\workspace\Maven_SVN_Jenkins02\JunitTest02\pom.xml install
[INFO] Scanning for projects...
[INFO] 
[INFO] -----------------------< com.maven:JunitTest02 >------------------------
[INFO] Building JunitTest02 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ JunitTest02 ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ JunitTest02 ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ JunitTest02 ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ JunitTest02 ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ JunitTest02 ---
[INFO] Surefire report directory: C:\Program Files (x86)\Jenkins\workspace\Maven_SVN_Jenkins02\JunitTest02\target\surefire-reports
-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.junit.exam01.DecoExamTest
This is test A
This is test B
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.094 sec

Results :

Tests run: 2, Failures: 0, Errors: 0, Skipped: 0

[JENKINS] Recording test results
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ JunitTest02 ---
[WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.BuildInfoRecorder$1; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ JunitTest02 ---
[WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.SurefireArchiver$2; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[INFO] Installing C:\Program Files (x86)\Jenkins\workspace\Maven_SVN_Jenkins02\JunitTest02\target\JunitTest02-0.0.1-SNAPSHOT.jar to C:\Windows\system32\config\systemprofile\.m2\repository\com\maven\JunitTest02\0.0.1-SNAPSHOT\JunitTest02-0.0.1-SNAPSHOT.jar
[INFO] Installing C:\Program Files (x86)\Jenkins\workspace\Maven_SVN_Jenkins02\JunitTest02\pom.xml to C:\Windows\system32\config\systemprofile\.m2\repository\com\maven\JunitTest02\0.0.1-SNAPSHOT\JunitTest02-0.0.1-SNAPSHOT.pom
[WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.MavenArtifactArchiver$2; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[WARNING] Attempt to (de-)serialize anonymous class hudson.maven.reporters.MavenFingerprinter$1; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.063 s
[INFO] Finished at: 2018-05-09T19:14:07+08:00
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving C:\Program Files (x86)\Jenkins\workspace\Maven_SVN_Jenkins02\JunitTest02\pom.xml to com.maven/JunitTest02/0.0.1-SNAPSHOT/JunitTest02-0.0.1-SNAPSHOT.pom
[JENKINS] Archiving C:\Program Files (x86)\Jenkins\workspace\Maven_SVN_Jenkins02\JunitTest02\target\JunitTest02-0.0.1-SNAPSHOT.jar to com.maven/JunitTest02/0.0.1-SNAPSHOT/JunitTest02-0.0.1-SNAPSHOT.jar
channel stopped
Email was triggered for: Always
Sending email for trigger: Always
Sending email to: **************@126.com
Finished: SUCCESS

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326529800&siteId=291194637