工具準備:
開始:
<profile>
<id>jdk-1.7</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.7</jdk>
</activation>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
</properties>
</profile>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
- 構建過程中,可能還會報編碼異常,需要在你項目的pom.xml中增加
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- 自動發佈到tomcat的話,需要安裝插件,不太好找,在插件裏搜一下aplication server,應該就能找到,需要配置tomcat的tomcat-users.xml,打開註釋:
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user username="tomcat" password="tomcat" roles="manager-gui,manager-script,manager-jmx,manager-status"/>
- 這裏還需要確保你的tomcat中的root下有那個manger的原始項目
- 第一個jenkins配置成功,留念:
Started by user anonymous
Building in workspace C:\Users\Administrator\.jenkins\jobs\MiceRp\workspace
Updating https://101.201.148.185/svn/沙箱/Mice/MiceRp at revision '2016-08-01T12:15:38.694 +0800'
D src\main\java\log4j.properties
D src\main\java\hanlp.properties
A src\main\resources\hanlp.properties
A src\main\resources\log4j.properties
At revision 543
Parsing POMs
[workspace] $ E:\Jdk\jdk1.7.0_80/bin/java -cp C:\Users\Administrator\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven31-agent-1.5.jar;E:\apache-maven-3.3.9\boot\plexus-classworlds-2.5.2.jar;E:\apache-maven-3.3.9/conf/logging jenkins.maven3.agent.Maven31Main E:\apache-maven-3.3.9 E:\Web\apache-tomcat-7.0.65-jenkins\webapps\jenkins\WEB-INF\lib\remoting-2.59.jar C:\Users\Administrator\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven31-interceptor-1.5.jar C:\Users\Administrator\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-commons-1.5.jar 53612
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven: -B -f C:\Users\Administrator\.jenkins\jobs\MiceRp\workspace\pom.xml install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MiceRp Maven Webapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MiceRp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 13 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ MiceRp ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MiceRp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ MiceRp ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ MiceRp ---
[JENKINS] Recording test results
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) @ MiceRp ---
[INFO] Packaging webapp
[INFO] Assembling webapp [MiceRp] in [C:\Users\Administrator\.jenkins\jobs\MiceRp\workspace\target\MiceRp]
[INFO] Processing war project
[INFO] Copying webapp resources [C:\Users\Administrator\.jenkins\jobs\MiceRp\workspace\src\main\webapp]
[INFO] Webapp assembled in [383 msecs]
[INFO] Building war: C:\Users\Administrator\.jenkins\jobs\MiceRp\workspace\target\MiceRp.war
[INFO] WEB-INF\web.xml already added, skipping
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ MiceRp ---
[INFO] Installing C:\Users\Administrator\.jenkins\jobs\MiceRp\workspace\target\MiceRp.war to C:\Users\Administrator\.m2\repository\com\mice\rp\MiceRp\0.0.1-SNAPSHOT\MiceRp-0.0.1-SNAPSHOT.war
[INFO] Installing C:\Users\Administrator\.jenkins\jobs\MiceRp\workspace\pom.xml to C:\Users\Administrator\.m2\repository\com\mice\rp\MiceRp\0.0.1-SNAPSHOT\MiceRp-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.294 s
[INFO] Finished at: 2016-08-01T12:16:06+08:00
[INFO] Final Memory: 18M/156M
[INFO] ------------------------------------------------------------------------
[JENKINS] Archiving C:\Users\Administrator\.jenkins\jobs\MiceRp\workspace\pom.xml to com.mice.rp/MiceRp/0.0.1-SNAPSHOT/MiceRp-0.0.1-SNAPSHOT.pom
[JENKINS] Archiving C:\Users\Administrator\.jenkins\jobs\MiceRp\workspace\target\MiceRp.war to com.mice.rp/MiceRp/0.0.1-SNAPSHOT/MiceRp-0.0.1-SNAPSHOT.war
channel stopped
Deploying C:\Users\Administrator\.jenkins\jobs\MiceRp\workspace\target\MiceRp.war to container Tomcat 7.x Remote
Redeploying [C:\Users\Administrator\.jenkins\jobs\MiceRp\workspace\target\MiceRp.war]
Undeploying [C:\Users\Administrator\.jenkins\jobs\MiceRp\workspace\target\MiceRp.war]
Deploying [C:\Users\Administrator\.jenkins\jobs\MiceRp\workspace\target\MiceRp.war]
Finished: SUCCESS