Jenkins常用插件之Deploy Plugin

该插件主要运用在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进行安装

第二步:编译工具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,查看结果

  5. 修改maven的settings.xml文件,在pluginGroups节点增加cargo插件,进行远程部署

第三步:修改Tomcat配置

  1. 修改tomcat的tomcat-users.xml文件,增加tomcat的manager用户

  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://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

  1. 创建一个maven项目的Job,名称为mavenTestWeb

  2. 添加Job的详细描述信息

  3. 配置源码管理

  4. 配置构建触发器

  5. 配置构建

  6. 构建后操作配置

  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
时间: 2024-10-13 04:28:46

Jenkins常用插件之Deploy Plugin的相关文章

Jenkins常用插件之MSBuild Plugin

该插件主要运用在.NET项目中,功能是"对.NET项目的源码进行编译". C#:可通过Visual Studio的项目文件(.csproj)和解决方案文件(.sln)进行编译 C++:可通过Visual Studio的项目文件(.vxcproj)和解决方案文件(.sln)进行编译 以下是使用该插件的具体步骤: 第一步:MSBuild相关软件下载和安装 在网上下载Microsoft Build Tools 2013,下载文件为BuildTools_Full.exe 在网上下载MSBuil

Jenkins常用插件之Cppcheck Plugin

工具简介 Cppcheck 是一个静态代码检查工具,支持C/C++代码:作为编译器的一种补充检查,Cppcheck主要对源代码执行以下检查: 1. 自动变量检查 2. 数组的边界检查 3. class类检查 4. 过期的函数,废弃函数调用检查 5. 异常内存使用,释放检查 6. 内存泄漏检查,主要是通过内存引用指针 7. 操作系统资源释放检查,中断,文件描述符等 8. 异常STL 函数使用检查 9. 代码格式错误,以及性能因素检查 基础使用 检查单个文件:cppcheck file.c 检查文件

Jenkins常用插件说明(持续更新)

本文主要记录在学习以及使用Jenkins过程中常用的对我们有帮助的插件,同时本文将会持续进行更新.如果大家发现有其他野很好用的插件,也欢迎参照下面的格式,在评论中进行回复反馈. 一.通用插件 1.Embeddable Build Status Icon 链接:https://ci.jenkins-ci.org/job/lib-jira-api/badge/ | https://wiki.jenkins-ci.org/display/JENKINS/Embeddable+Build+Status+

jenkins常用插件

备份 ThinBackup 设置界面 备份路径中备份记录 选择还原 :项目和插件都会有备份 权限管理 Manage and Assign Roles 我这里根据项目名前缀分配,详细使用可自己尝试 比较简单 原文地址:https://www.cnblogs.com/cjh-notes/p/10806847.html

Jenkins插件HTML Publisher Plugin的使用

前提: 下载插件HTML Publisher plugin 一.安装 安装好HTML Publisher plugin之后,会在新建或者编辑项目时,在[增加构建后操作步骤]出现[Publish HTML reports]的选项.如下: 二.配置 点击上面构建步骤后,在这里会出现配置项目: 点击[增加]进行配置,在配置之后,先看下每一项的说明,以下来自google翻译: 按照上面的说明,我的配置如下: 我只配置了HTML directory to archive的项,上面说了,这个路径是相对于工作

maven常用插件配置详解

常用插件配置详解Java代码    <!-- 全局属性配置 --> <properties> <project.build.name>tools</project.build.name> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> project.build.name:  用来定义war包名称  proje

maven常用插件

有用插件: Maven Release Plugin 版本发布; cargo-maven2-plugin 自动化部署; jetty-maven-plugin web测试; maven-gpg-plugin, GPG:http://www.gnupg.org/download/ 给maven构件加密        hkp://pgp.mit.edu 美国麻省理工大学公钥服务器 maven-surefire-plugin: 单元测试,集成测试 maven-site-plugin:生成站点 //mvn

ElasticSearch之常用插件安装命令

#head监控安装,推荐 bin/plugin -install mobz/elasticsearch-head #bigdesk集群状态,推荐 bin/plugin -install lukas-vlcek/bigdesk #marvel监控安装 bin/plugin -i elasticsearch/marvel/latest #es-sql安装,网页内有详细说明 https://github.com/NLPchina/elasticsearch-sql #jdbc-river安装(rive

eclipse 常用插件

转自:http://blog.csdn.net/fmynjy/article/details/51500989 开发过程中的常用Eclipse插件,按字母排序: (1)    AmaterasUML        介绍:Eclipse的UML插件,支持UML活动图,class图,sequence图,usecase图等:支持与Javaclass/interface之间的相互导入导出.        官方网站:http://amateras.sourceforge.jp/cgi-bin/fswiki