anyuan2002.com - vwin网

搜索: 您的位置主页 > 网络频道 > 阅读资讯:Jenkins常用插件之Deploy Plugin

Jenkins常用插件之Deploy Plugin

2019-04-01 05:54:01 来源:www.anyuan2002.com 【

该插件主要运用在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下载和安装

  1. 在网上下载Deploy Plugin插件,下载文件为deploy.hpi
  2. 在jenkins中安装Deploy Plugin插件,系统管理–>插件管理–>高级上传deploy.hpi进行安装
    Jenkins常用插件之Deploy Plugin

第二步:编译工具maven的下载和配置

  1. 在网上下载maven安装包apache-maven-3.3.9-bin.zip
  2. 解压apache-maven-3.3.9-bin.zip至D:\BuildTool
  3. 设置环境变量
    —新建系统变量:MAVEN_HOME,值为:D:\BuildTool\apache-maven-3.3.9
    —设置PATH变量,追加值为:;%MAVEN_HOME%\bin
  4. 验证环境变量–打开CMD,输入mvn -v,查看结果
    Jenkins常用插件之Deploy Plugin
  5. 修改maven的settings.xml文件,在pluginGroups节点增加cargo插件,进行远程部署
    Jenkins常用插件之Deploy Plugin

第三步:修改Tomcat配置

  1. 修改tomcat的tomcat-users.xml文件,增加tomcat的manager用户
    Jenkins常用插件之Deploy Plugin
  2. 启动tomcat

第四步:新建示例maven项目WebProject

  1. 运用Eclipse创建一个maven项目,名称为WebProject
  2. 修改构建文件pom.xml,主要注意build节点的配置
<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://vwin德赢00: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

  1. 创建一个maven项目的Job,名称为mavenTestWeb
    Jenkins常用插件之Deploy Plugin
  2. 添加Job的详细描述信息
    Jenkins常用插件之Deploy Plugin
  3. 配置源码管理
    Jenkins常用插件之Deploy Plugin
  4. 配置构建触发器
    Jenkins常用插件之Deploy Plugin
  5. 配置构建
    Jenkins常用插件之Deploy Plugin
  6. 构建后操作配置
    Jenkins常用插件之Deploy Plugin
  7. 构建验证,查看控制台输出的日志信息
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\jobs\mavenTestWeb\workspace\target
[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 ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\Program Files\Jenkins\jobs\mavenTestWeb\workspace\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ WebProject ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ WebProject ---
[INFO] No tests to run.
[JENKINS] Recording test results
[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 [18 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.408 s
[INFO] Finished at: 2016-04-17T14:35:08+08:00
[INFO] Final Memory: 17M/226M
[INFO] ------------------------------------------------------------------------
[JENKINS] Archiving D:\Program Files\Jenkins\jobs\mavenTestWeb\workspace\pom.xml to me.gacl.maven/WebProject/0.0.1-SNAPSHOT/WebProject-0.0.1-SNAPSHOT.pom
[JENKINS] Archiving D:\Program Files\Jenkins\jobs\mavenTestWeb\workspace\target\WebProject.war to me.gacl.maven/WebProject/0.0.1-SNAPSHOT/WebProject-0.0.1-SNAPSHOT.war
channel stopped
Deploying D:\Program Files\Jenkins\jobs\mavenTestWeb\workspace\target\WebProject.war to container Tomcat 7.x Remote
 [D:\Program Files\Jenkins\jobs\mavenTestWeb\workspace\target\WebProject.war] is not deployed. Doing a fresh deployment.
 Deploying [D:\Program Files\Jenkins\jobs\mavenTestWeb\workspace\target\WebProject.war]
Finished: SUCCESS
 
 

本文地址:http://www.anyuan2002.com/a/question/100193.html
Tags: 插件 Jenkins Deploy
编辑:vwin网
关于我们 | 联系我们 | 友情链接 | 网站地图 | Sitemap | App | 返回顶部