标签:修改 项目打包 目录 title 高级 工具 filter logging 验证
该插件主要运用在Java项目中,功能是“将成功编译的War/Jar包部署到远程的应用服务器上,该功能的实现主要基于Cargo。当前支持的应用服务器版本如下:
- Tomcat 4.x/5.x/6.x/7.x
- JBoss 3.x/4/x
- Glassfish 2.x/3.x
以下是使用该插件的具体步骤:
第一步:Deploy Plugin下载和安装
第二步:编译工具maven的下载和配置
第三步:修改Tomcat配置
第四步:新建示例maven项目WebProject
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.gacl.maven</groupId>
<artifactId>WebProject</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>WebProject Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<!-- 将Web项目自动部署到tomcat服务器的相关 配置信息-->
<build>
<!-- 将WebProject项目打包成WebProject.war自动部署到tomcat服务器的webapps目录下面 -->
<finalName>WebProject</finalName>
<!-- 利用cargo插件把项目部署到远程的tomcat容器中 -->
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.2.3</version>
<configuration>
<container>
<!-- 指明使用的tomcat服务器版本 -->
<containerId>tomcat7x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<cargo.remote.username>admin</cargo.remote.username>
<cargo.remote.password>admin</cargo.remote.password>
<cargo.tomcat.manager.url>http://192.168.1.100:8080/manager</cargo.tomcat.manager.url>
</configuration>
</configuration>
<executions>
<execution>
<phase>deploy</phase>
<goals>
<goal>redeploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
第五步:在Jenkins中构建项目mavenTestWeb
Started by user anonymous
Building 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