该插件主要运用在项目中,功能是“将成功编译的War/Jar包部署到远程的应用服务器上,该功能的实现主要基于Cargo。当前支持的应用服务器版本如下:
- Tomcat 4.x/5.x/6.x/7.x - JBoss 3.x/4/x - Glassfish 2.x/3.x 以下是使用该插件的具体步骤:第一步:Deploy Plugin下载和安装
- 在网上下载插件,下载文件为deploy.hpi
- 在jenkins中安装Deploy Plugin插件,系统管理–>插件管理–>高级上传deploy.hpi进行安装
第二步:编译工具maven的下载和配置
- 在网上下载安装包apache-maven-3.3.9-bin.zip
- 解压apache-maven-3.3.9-bin.zip至D:\BuildTool
- 设置环境变量 —新建系统变量:MAVEN_HOME,值为:D:\BuildTool\apache-maven-3.3.9 —设置PATH变量,追加值为:;%MAVEN_HOME%\bin
- 验证环境变量–打开CMD,输入mvn -v,查看结果
- 修改maven的settings.xml文件,在pluginGroups节点增加cargo插件,进行远程部署
第三步:修改Tomcat配置
- 修改tomcat的tomcat-users.xml文件,增加tomcat的manager用户
- 启动tomcat
第四步:新建示例maven项目WebProject
- 运用Eclipse创建一个maven项目,名称为
- 修改构建文件pom.xml,主要注意build节点的配置
4.0.0 me.gacl.maven WebProject war 0.0.1-SNAPSHOT WebProject Maven Webapp http://maven.apache.org junit junit 3.8.1 test WebProject org.codehaus.cargo cargo-maven2-plugin 1.2.3 tomcat7x remote runtime admin admin http://192.168.1.100:8080/manager deploy redeploy
- 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
- 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
第五步:在Jenkins中构建项目mavenTestWeb
- 创建一个maven项目的Job,名称为mavenTestWeb
- 添加Job的详细描述信息
- 配置源码管理
- 配置构建触发器
- 配置构建
- 构建后操作配置
- 构建验证,查看控制台输出的日志信息
Started by user anonymousBuilding in workspace D:\Program Files\Jenkins\jobs\mavenTestWeb\workspace Checking out a fresh workspace because there's no workspace at D:\Program Files\Jenkins\jobs\mavenTestWeb\workspace Cleaning local Directory . Checking out https://pc-20160123cxrq/svn/MyRepository/trunk/%E6%BA%90%E4%BB%A3%E7%A0%81/WebProject at revision '2016-04-17T14:35:01.952 +0800' A pom.xml A .classpath A .project A .settings A .settings\org.eclipse.jdt.core.prefs A .settings\org.eclipse.m2e.core.prefs A src A src\main A src\main\resources A src\main\webapp A src\main\webapp\WEB-INF A src\main\webapp\WEB-INF\web.xml A src\main\webapp\index.jsp At revision 39 No changes for https://pc-20160123cxrq/svn/MyRepository/trunk/%E6%BA%90%E4%BB%A3%E7%A0%81/WebProject since the previous build [workspace] $ cmd.exe /C '"D:\CItools\apache-maven-3.3.9\bin\mvn.cmd clean install -Dmaven.test.skip=true && exit %%ERRORLEVEL%%"' [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building WebProject Maven Webapp 0.0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ WebProject --- [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ WebProject --- [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) @ WebProject --- [INFO] No sources to compile [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ WebProject --- [INFO] Not copying test resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ WebProject --- [INFO] Not compiling test sources [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ WebProject --- [INFO] Tests are skipped. [INFO] [INFO] --- maven-war-plugin:2.2:war (default-war) @ WebProject --- [INFO] Packaging webapp [INFO] Assembling webapp [WebProject] in [D:\Program Files\Jenkins\jobs\mavenTestWeb\workspace\target\WebProject] [INFO] Processing war project [INFO] Copying webapp resources [D:\Program Files\Jenkins\jobs\mavenTestWeb\workspace\src\main\webapp] [INFO] Webapp assembled in [20 msecs] [INFO] Building war: D:\Program Files\Jenkins\jobs\mavenTestWeb\workspace\target\WebProject.war [INFO] WEB-INF\web.xml already added, skipping [INFO] [INFO] --- maven-install-plugin:2.4:install (default-install) @ WebProject --- [INFO] Installing D:\Program Files\Jenkins\jobs\mavenTestWeb\workspace\target\WebProject.war to C:\.m2\repository\me\gacl\maven\WebProject\0.0.1-SNAPSHOT\WebProject-0.0.1-SNAPSHOT.war [INFO] Installing D:\Program Files\Jenkins\jobs\mavenTestWeb\workspace\pom.xml to C:\.m2\repository\me\gacl\maven\WebProject\0.0.1-SNAPSHOT\WebProject-0.0.1-SNAPSHOT.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.037 s [INFO] Finished at: 2016-04-17T14:35:05+08:00 [INFO] Final Memory: 13M/220M [INFO] ------------------------------------------------------------------------ Parsing POMs [workspace] $ "D:\Program Files\Java\jdk1.7.0_79/bin/java" -cp "D:\Program Files\Jenkins\plugins\maven-plugin\WEB-INF\lib\maven31-agent-1.5.jar;D:\CItools\apache-maven-3.3.9\boot\plexus-classworlds-2.5.2.jar;D:\CItools\apache-maven-3.3.9/conf/logging" jenkins.maven3.agent.Maven31Main D:\CItools\apache-maven-3.3.9 "D:\Program Files\Jenkins\war\WEB-INF\lib\remoting-2.53.3.jar" "D:\Program Files\Jenkins\plugins\maven-plugin\WEB-INF\lib\maven31-interceptor-1.5.jar" "D:\Program Files\Jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-commons-1.5.jar" 6271 <===[JENKINS REMOTING CAPACITY]===>channel started Executing Maven: -B -f D:\Program Files\Jenkins\jobs\mavenTestWeb\workspace\pom.xml clean install [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building WebProject Maven Webapp 0.0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ WebProject --- [INFO] Deleting D:\Program Files\Jenkins\jobs