jenkins maven tomcat做持续集成的时候几个关键配置

jenkins maven tomcat做持续集成的时候几个关键配置

maven 采用 maven 3.0以上的版本。tomcat 采用 tomcat 7.0 以上的版本

1. tomcat 配置用户账号和权限

tomcat-users.xml

?
1
2
3
4
5
6
< role rolename = "manager" />
< role rolename = "manager-script" />
< role rolename = "manager-gui" />
< role rolename = "manager-jmx" />
< role rolename = "manager-status" /> 
< user username = "admin" password = "admin" roles = "manager,manager-gui,manager-script,manager-jmx,manager-status" />

2. maven 配置 tomcat 账号

setting.xml 文件


?
1
2
3
4
5
6
7
< servers >
     < server >
       < id >servername</ id >
       < username >admin</ username >
       < password >admin</ password >
     </ server >
   </ servers >
3. 项目 pom.xml 配置


3.1 build 配置节配置 tomcat 发布插件,注意 server 必须与2中一致,增加update 配置项,更新发布的文件,

tomcat 的发布路径为 http://serverip:port/manager/text


?
1
2
3
4
5
6
7
8
9
10
11
12
13
< plugin >
     < groupId >org.apache.tomcat.maven</ groupId >
     < artifactId >tomcat7-maven-plugin</ artifactId >
     < version >2.1</ version >
     < configuration >
         < url >http://192.168.0.51:8081/manager/text</ url >
         < update >true</ update >
         < server >servername</ server >
         < username >admin</ username >
         < password >admin</ password >
         < path >/info</ path >
     </ configuration >
</ plugin >
3.2 build 配置节配置部署时测试相关,忽略测试



?
1
2
3
4
5
6
7
8
< plugin >
     < groupId >org.apache.maven.plugins</ groupId >
     < artifactId >maven-surefire-plugin</ artifactId >
     < version >2.14</ version >
     < configuration >
         < skipTests >true</ skipTests >
     </ configuration >
</ plugin >
buid下所有插件例子



?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
                 < plugins >
             < plugin >
                 < artifactId >maven-compiler-plugin</ artifactId >
                 < version >2.3.2</ version >
                 < configuration >
                     < source >1.6</ source >
                     < target >1.6</ target >
                     < encoding >UTF-8</ encoding >
                 </ configuration >
             </ plugin >
             < plugin >
                 < artifactId >maven-resources-plugin</ artifactId >
                 < version >2.5</ version >
                 < executions >
                     < execution >
                         < phase >compile</ phase >
                     </ execution >
                 </ executions >
             </ plugin >
             < plugin >
                 < artifactId >maven-dependency-plugin</ artifactId >
                 < version >2.4</ version >
                 < executions >
                     < execution >
                         < phase >compile</ phase >
                         < goals >
                             < goal >copy-dependencies</ goal >
                         </ goals >
                         < configuration >
                             < outputDirectory >src/main/webapp/WEB-INF/lib</ outputDirectory >
                         </ configuration >
                     </ execution >
                 </ executions >
             </ plugin >
             < plugin >
                 < artifactId >maven-clean-plugin</ artifactId >
                 < version >2.4.1</ version >
                 < configuration >
                     < filesets >
                         < fileset >
                             < directory >src/main/webapp/WEB-INF/lib</ directory >
                             < followSymlinks >false</ followSymlinks >
                         </ fileset >
                     </ filesets >
                 </ configuration >
             </ plugin >
             < plugin >
                 < groupId >org.apache.maven.plugins</ groupId >
                 < artifactId >maven-surefire-plugin</ artifactId >
                 < version >2.14</ version >
                 < configuration >
                     < skipTests >true</ skipTests >
                 </ configuration >
             </ plugin >
             < plugin >
                 <!--<groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId>
                     <version>1.1</version> -->
                 < groupId >org.apache.tomcat.maven</ groupId >
                 < artifactId >tomcat7-maven-plugin</ artifactId >
                 < version >2.1</ version >
                 < configuration >
                     < url >http://192.168.0.51:8081/manager/text</ url >
                     < update >true</ update >
                     < server >booksair</ server >
                     < username >admin</ username >
                     < password >admin</ password >
                     < path >/info</ path >
                 </ configuration >
             </ plugin >
         </ plugins >

4. jenkins 项目配置

jenkins mavne goal目标为(针对tomcat 7)clean install tomcat7:deploy

tomcat 配置 

WAR/EAR files:**/site.war

tomcat url: http://serverip:port/ (这里不用配置项目路径 或者 manager 路径,否则会出现 Unkown /manager/text/list 错误)

    这里只是概要说明了下集成的主要配置,如果有不完整的大家可以提出来,我补充下。


原文地址:http://my.oschina.net/congqian/blog/112782

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值