jenkins + maven + svn

工具准备:
开始:
  • 准备一个maven项目:根据这个来就可以http://www.cnblogs.com/leiOOlei/p/3361633.html,需要注意的是,有可能会找不到 “further configuration available”,这个时候把“Dynamic web module”勾掉,然后退出再进就可以了,奇葩。搞定之后上传svn即可。
  • Jenkins的安装:本想用jenkins2.7,但是插件总是安装失败,最终下载1.65版的war,war版本的好处在于放到tomcat里直接就可以用了。可根据这个一步一步即可:http://www.cnblogs.com/sunzhenchao/archive/2013/01/30/2883289.html
  • Svn中文目录不识别的问题,在确认tomcat设置了编码格式的前提下,我是采用在jenkins中升级插件到最新版本的方式解决的(无奈自动下载失败,直接手动下载插件,然后在控制台中可手动上传安装成功的)
  • 执行构建,发生错误,Maven编译问题,需要在Maven的setting.xml文件中增加
<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>


  • 在你项目的pom.xml中增加
     <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





  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值