maven---10使用Jenkins进行持续集成

0推荐文章和网站

参考文章
使用Jenkins配置Git+Maven的自动化构建
jenkins git插件安装
Jenkins+Github持续集成
手动下载Jenkins插件网址

1持续集成的作用、过程和优势

  • 持续集成就是快速、高频率地自动构建项目的所有源码,并为项目成员提供丰富的反馈信息。
    • 快速:集成速度要尽可能的块,开发人员不希望自己提交的代码提交半天后才得到反馈。
    • 高频率:频率越高越好,例如每隔一个小时,这样问题就可以尽早地反映出来。
    • 自动*:持续集成应该自动触发并执行的,不应该有手工参与。
    • 构建:包括编译、测试、审查、打包、部署等工作。
    • 所有源码:所有团队成员提交到代码库里的最新的源代码。
    • 反馈:持续集成应该通过各种快捷的方式告诉团队最新的集成状态,当集成失败,反馈报告应该尽可能地反映失败的具体细节。

1.1典型应用场景

开发人员对代码做了一些修改,在本地运行构建并确认无误之后,将更改提交到代码库(git、svn等)。具有高配置硬件的持续集成服务器每隔30分钟查询代码库一次,发现更新之后,签出所有最新的源代码,然后调用自动化构建工具(maven、ant等)构建项目,该过程包括编译、测试、审查、打包和部署等。然而不幸的是,另外一名开发人员在这一时间段也提交了代码更改,两处更改导致了某些测试的失败,持续集成服务器基于这些失败的测试创建一个报告,并自动发送给相关开发人员。开发人员收到报告后,立即着手调查选用,并尽快修复。

持续集成流程

2Jenkins简介

Jenkins是一款持续集成工具,它的前身是Hudson。使用jenkins还不能够完成持续集成工作,还需要版本控制工具(git、svn等)和项目构建工具(maven、ant等)配合才可以完成。

3.准备

  • 首先需要理解的是,Jenkins是帮我们将代码进行统一的编译打包、还可以放到tomcat容器中进行发布。
  • 意思是我们通过配置,将以前:编译、打包、上传、部署到Tomcat中的过程交由Jenkins,Jenkins通过给定的代码地址URL,将代码拉取到其“宿主服务器”(这是我个人的称呼,在下边会用到,就是Jenkins的安装位置),进行编译、打包和发布到容器中。
  • 因此我们可以注意到的是,在Jenkins的宿主服务器中必须要有可以进行:代码clone(Git)、代码编译(Maven)、代码运行(Tomcat)的基本环境,其他文章上来就是安装jenkins,忽略了一些基本的配置。
  • 下面我写的案例是一个普通的java项目,涉及到的软件有git、maven、nexus、tomcat、jekins。所以需要确保已经安装。关于git的安装上面文章有介绍,关于maven,nexus的安装我前面文章有介绍。

3.1安装jenkins

  • jenkins是一个war文件,下载jenkins,我下载的是2.19.4版本

  • 运行前先配置jenkins的工作目录,jenkins的工作目录会随着任务的变多而占用磁盘空间变大,所以在此之前可以配置一下工作目录。请看maven---12Jenkins工作目录

  • 下载后可以通过 java -jar jenkins.war --httpPort=8080直接运行(其内置了jetty服务器),或者直接放到tomcat的webapps目录下了,再启动tomcat。下面以tomcat方式运行。然后访问http://localhost:8080/jenkins 就进入jenkins管理界面了。

  • 第一次进入网站,jenkins会生成jenkins的工作目录,然后让你输入管理员密码进入,该密码你根据提示信息去工作目录中就可以找到。密码会存在jenkins的工作目录中的secrets\initialAdminPass文件中。E:\soft\jenkins\jenkins_work\secrets\initialAdminPassword

  • 密码输入后进入安装插件界面,点击推荐安装,如果此时出现如下界面,则尝试重启jenkins,重启tomcat,一般情况的重启方法是在浏览器输入http://localhost:8080/restart,但是这种情况还是重启tomcat 。

    Paste_Image.png

  • 如果jenkins一直在启动状态有可能内存溢出了,为你的tomcat的虚拟机设置大一点运行内存。

Paste_Image.png

4配置插件

  • 进入jenkins会让你下载一些必要的插件和推荐的插件,需要安装某些插件才可以使用一些工具,比如jenkins默认不支持git,所以要下载git相关插件才可以让jenkins支持。而网络原因有可能会下载失败,所以还需要手动下载。
jenkins第一次下载插件
部分插件安装失败
  • 插件安装失败如果没有进入主界面执行http://localhost:8080/restart 重启后。进入后就是手动下载需要的插件了,包括下载失败的插件都需要手动下载,在配置上来。
  • 有些插件的安装需要依赖其他插件,所以如果某一个插件安装失败会影响到其它插件的安装。
  • 对于插件的精确选择,我还不是太明白,只是知道需要git、github、maven,在下的时候因为插件间依赖原因也多下了其它的。
  • 插件的参考来自于上面两篇文章。

4.1确定需要下载的插件

  • 大概确定要下插件我的这个jenkins版本内置了maven插件,所以主要下载git、github和jenkins推荐的必要插件,最终我因为还不是太懂好像也下了一些用不到的插件,我一开始也没有下那么多,但是在建任务时发现有些配置没有,所以又去[插件管理]中寻找相关插件。

4.2联网下载的插件

  • 第一次登陆http://localhost:8080/jenkins 网站会让你下载相关插件,我选了上面的几个插件。然后会进入下载等待,最后会给你提示下载的成功情况,有的插件下载失败有的成功了。

4.3手动下载插件

在Jenkins一开始会让你选择安装插件,但是由于网络原因会下载失败,有的插件安装失败,所以需要手动下载在上传上传。

4.3.1寻找需要下载的插件

有的插件安装失败,进入管理界面就会出现如下错误:


插件安装失败

案例:上面错误有两个(这是我解决了部分后还剩下的),先解决pipeline:Stage View plugin v2.4插件安装失败。根据提示发现失败原因是需要先安装pipeline-rest-api v2.4插件。
根据错误提示去插件网站搜索(Ctr+f)需要下载的pipeline-rest-api v2.4插件。

4.3.2下载需要的插件

搜索插件
选择要下载的版本

下载的是一个一.hpi结尾的文件。

4.3.3上传插件

系统管理–管理插件–高级Tab->上传插件

  • 上传插件


    Paste_Image.png
  • 查看安装状态


    安装成功
安装失败情况

4.4重启jekins

有的插件安装完成需要重启才能生效(会有提示),重启就是重启tomcat就可以。重启完后已安装的插件就不会出现错误提示了。

没有错误插件提示了

5配置jenkins全局工具

Paste_Image.png

6新建一个任务

6.1.1任务需求

  • 通过持续集成不断的把一个java项目的最新构件自动发布到nexus仓库中,其中会通过反馈机制返回集成的状态和错误报告。(但是反馈好像没起作用,有可能是邮箱配错了,猜测)
  • 源码管理:github,项目构建工具maven,项目生成构件发布到nexus上。
  • 在jenkins中新建一个自由风格项目,自由风格项目不仅支持maven项目还支持其他类型项目。


    Paste_Image.png

6.1.2任务配置(写的不是太详细后面在补充)

6.1.2.1概念解释

  • 任务需要配置旧构建丢弃策略、源码管理、构建触发器、构建、构建后操作。
  • 丢弃策略:
    下图是hudson的丢弃策略同样适用于jenkins,因为hudson是jenkins前身。


    丢弃策略
  • 源码管理:
    项目源码管理我选择的是git源码管理工具,所以我已经在github上创建了一个cidemo仓库。配置它的时候除了配置项目地址,还要配置git在本机的认证信息,该处参考了上面两篇文章。
  • 构建触发器:
触发器策略
Paste_Image.png
  • 构建
    让jenkins选择用什么命令构建项目,在前面我们配置maven所以会选择[invoke top-level Maven targets]进行配置。


    Paste_Image.png
  • 构建后操作
    该步骤配置构建完后的一些任务,有哪些可以在这里配置呢?任务测试报告,邮件反馈等。
    其中邮件反馈最重要,下一篇文件介绍maven---11配置jenkins的邮件反馈

6.1.2.2建一个helloword任务

PollSCM表达式
Git项中Credentials点击add后的的配置
触发器和构建环境
  • 上面触发条件的Poll SCM说明有误,应该是固定时间去轮询源码库,发现有更新的时候才构建本项目
    配置生成测试报告

6.1.3jenkins中的已建好的任务

首页显示jenkins中所有任务
  • 在jenkins首页显示所有任务。
    描述任务有几个属性,其中:
  • 第一列状态(S):任务状态,使用颜色表示任务当前状态。
    • 蓝色:任务最近一次的构建是成功的。
    • 红色:任务最近一次的构建是失败的。
    • 黄色:任务最近一次的构建是成功的,但是不稳定(主要因为有失败的测试)。
    • 灰色:任务从未被执行过或者被禁用。
    • 图标闪烁:任务正在执行一次构建
  • 第二列天气(W):使用天气表示任务长期的一个状态
Paste_Image.png
Paste_Image.png
  • 任务不够健康时要尽快采取修复措施。
  • 其它属性看一下就明白了。
  • 点击项目名称就可以进入项目查看项目的一些构建情况。
任务界面
  • 菜单里的工作空间就是源码库管理的项目本下载在本地的位置,里面可以看到项目源码。

6.2编写项目并上传到github上

6.2.1 clone项目导本地

  • 首先克隆github上项目cidemo到本地。
git clone https://github.com/zlcook/cidemo.git

6.2.2编写代码

  • 我直接把maven---3手写一个helloWord中的maven项目内容拷贝到该目录下。(这个项目还不能满足任务的要求下面会跟随问题一步一步完善)。
  • 项目包含的内容
    • pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>com.zlcook.studymvn</groupId>
  <artifactId>helloword</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>maven helloword project</name>
<dependencies>
 <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.10</version>
    <scope>test</scope>
  </dependency> 
</dependencies>
<build>
    <plugins>
    <!--配置插件将main方法的类信息添加到manifest中,从而可以通过命令[java -jar 架包.jar]来执行生成的jar包-->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>2.4.3</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <transformers>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                  <mainClass>com.zlcook.studymvn.helloword.HelloWord</mainClass>
                </transformer>
              </transformers>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
  • 主代码:src\main\java\com\zlcook\studymvn\helloword\HelloWord.java
package com.zlcook.studymvn.helloword;
public class HelloWord
{
    public String say(){
        return "hello maven";
    }
    public static void main(String[] args){
        System.out.print(new HelloWord().say());
    }
}
  • 测试代码:src\test\java\com\zlcook\studymvn\helloword\HelloWordTest.java
package com.zlcook.studymvn.helloword;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class HelloWordTest
{
    @Test
    public void testSay(){
        HelloWord helloWord = new HelloWord();
        String result = helloWord.say();
        assertEquals("hello maven",result); 
        
    }
}
cidemo仓库下内容

6.2.3提交到github上

在cidemo目录下进行如下操作

  • 查看变动文件
    git status

  • 添加所有文件到缓存中
    git add .

  • 提交文件到本地仓库
    git commit -m "第一次提交"

  • 提交到github上的master分支
    git push origin HEAD:master

  • 填写github的用户名和密码

Paste_Image.png
  • 完成

6.3构建项目

  • 在jenkins的helloword任务(任务名称和github上的仓库名称取得不一致,当然一致最好)执行“立即构建”。

6.3.1第一次构建

6.3.1.1构建结果失败

Started by user zlcook
Building in workspace C:\Windows\system32\config\systemprofile\.jenkins\workspace\helloword
 > D:\Soft\git\Git\bin\git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > D:\Soft\git\Git\bin\git.exe config remote.origin.url https://github.com/zlcook/cidemo.git # timeout=10
Fetching upstream changes from https://github.com/zlcook/cidemo.git
 > D:\Soft\git\Git\bin\git.exe --version # timeout=10
using GIT_SSH to set credentials 
 > D:\Soft\git\Git\bin\git.exe fetch --tags --progress https://github.com/zlcook/cidemo.git +refs/heads/*:refs/remotes/origin/*
 > D:\Soft\git\Git\bin\git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
 > D:\Soft\git\Git\bin\git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision e75623ce6b045f7db3667c1dccfb3e3cc61e21c7 (refs/remotes/origin/master)
 > D:\Soft\git\Git\bin\git.exe config core.sparsecheckout # timeout=10
 > D:\Soft\git\Git\bin\git.exe checkout -f e75623ce6b045f7db3667c1dccfb3e3cc61e21c7
 > D:\Soft\git\Git\bin\git.exe rev-list e75623ce6b045f7db3667c1dccfb3e3cc61e21c7 # timeout=10
[helloword] $ cmd.exe /C "D:\Soft\maven\apache-maven-3.3.3\bin\mvn.cmd -s D:\Soft\maven\apache-maven-3.3.3\conf\settings.xml clean deploy && exit %%ERRORLEVEL%%"
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building maven helloword project 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.apache.maven.plugins:maven-resources-plugin:jar:2.6 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.109 s
[INFO] Finished at: 2016-11-30T15:07:16+08:00
[INFO] Final Memory: 5M/123M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failure to find org.apache.maven.plugins:maven-resources-plugin:jar:2.6 in http://172.19.201.155:8081/repository/maven-public/ was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE

6.3.1.2第一次失败原因及解决方法

6.3.2第二次构建

6.3.2.1构建结果失败

Started by user zlcook
Building in workspace C:\Windows\system32\config\systemprofile\.jenkins\workspace\helloword
 > D:\Soft\git\Git\bin\git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > D:\Soft\git\Git\bin\git.exe config remote.origin.url https://github.com/zlcook/cidemo.git # timeout=10
Fetching upstream changes from https://github.com/zlcook/cidemo.git
 > D:\Soft\git\Git\bin\git.exe --version # timeout=10
using GIT_SSH to set credentials 
 > D:\Soft\git\Git\bin\git.exe fetch --tags --progress https://github.com/zlcook/cidemo.git +refs/heads/*:refs/remotes/origin/*
 > D:\Soft\git\Git\bin\git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
 > D:\Soft\git\Git\bin\git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision e75623ce6b045f7db3667c1dccfb3e3cc61e21c7 (refs/remotes/origin/master)
 > D:\Soft\git\Git\bin\git.exe config core.sparsecheckout # timeout=10
 > D:\Soft\git\Git\bin\git.exe checkout -f e75623ce6b045f7db3667c1dccfb3e3cc61e21c7
 > D:\Soft\git\Git\bin\git.exe rev-list e75623ce6b045f7db3667c1dccfb3e3cc61e21c7 # timeout=10
[helloword] $ cmd.exe /C "D:\Soft\maven\apache-maven-3.3.3\bin\mvn.cmd -s D:\Soft\maven\apache-maven-3.3.3\conf\settings.xml clean deploy && exit %%ERRORLEVEL%%"
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building maven helloword project 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://172.19.201.155:8081/repository/maven-public/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.pom
2/8 KB   
6/8 KB   
8/8 KB   
         
Downloaded: http://172.19.201.155:8081/repository/maven-public/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.pom (8 KB at 2.9 KB/sec)
Downloading: http://172.19.201.155:8081/repository/maven-public/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.jar
2/29 KB   
6/29 KB   
10/29 KB   
14/29 KB   
18/29 KB   
22/29 KB   
26/29 KB   
29/29 KB   
           
Downloaded: http://172.19.201.155:8081/repository/maven-public/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.jar (29 KB at 18.0 KB/sec)
Downloading: http://172.19.201.155:8081/repository/maven-public/org/apache/maven/plugins/maven-compiler-plugin/3.1/maven-compiler-plugin-3.1.pom
           
Downloaded: http://172.19.201.155:8081/repository/maven-public/org/apache/maven/plugins/maven-compiler-plugin/3.1/maven-compiler-plugin-3.1.pom (0 B at 0.0 KB/sec)
Downloading: http://172.19.201.155:8081/repository/maven-public/org/apache/maven/plugins/maven-plugins/24/maven-plugins-24.pom
           
Downloaded: http://172.19.201.155:8081/repository/maven-public/org/apache/maven/plugins/maven-plugins/24/maven-plugins-24.pom (0 B at 0.0 KB/sec)
Downloading: http://172.19.201.155:8081/repository/maven-public/org/apache/maven/plugins/maven-compiler-plugin/3.1/maven-compiler-plugin-3.1.jar
....省略下载各种构件
Downloaded: http://172.19.201.155:8081/repository/maven-public/org/codehaus/plexus/plexus-utils/3.0.22/plexus-utils-3.0.22.jar (0 B at 0.0 KB/sec)
           
Downloaded: http://172.19.201.155:8081/repository/maven-public/com/google/guava/guava/11.0.2/guava-11.0.2.jar (0 B at 0.0 KB/sec)
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing C:\Windows\System32\config\systemprofile\.jenkins\workspace\helloword\target\helloword-0.0.1-SNAPSHOT.jar with C:\Windows\System32\config\systemprofile\.jenkins\workspace\helloword\target\helloword-0.0.1-SNAPSHOT-shaded.jar
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ helloword ---
[INFO] Installing C:\Windows\System32\config\systemprofile\.jenkins\workspace\helloword\target\helloword-0.0.1-SNAPSHOT.jar to D:\Soft\maven\maven_jar\repository\com\zlcook\studymvn\helloword\0.0.1-SNAPSHOT\helloword-0.0.1-SNAPSHOT.jar
[INFO] Installing C:\Windows\System32\config\systemprofile\.jenkins\workspace\helloword\pom.xml to D:\Soft\maven\maven_jar\repository\com\zlcook\studymvn\helloword\0.0.1-SNAPSHOT\helloword-0.0.1-SNAPSHOT.pom
[INFO] 
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ helloword ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 04:11 min
[INFO] Finished at: 2016-11-30T15:17:39+08:00
[INFO] Final Memory: 19M/159M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project helloword: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE

6.3.2.2第二次失败原因分析及解决办法

  • 小发现:首先我们发现本地maven去nexus私服上检查构件更新时发现maven-resources-plugin没有(上一步删掉了),然后进行下载,后面对于其他的构件进行检查发现没有更新所以都没有下载(0 B at 0.0 KB/sec)。
  • a.分析原因:
    没有为项目配置构件发布的位置。
Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project helloword: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
<?xml version="1.0" encoding="UTF-8"?>
<project>
...
   <!--设置项目统一构件文件的编码-->
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   </properties>
...
  <!--配置项目生成的构件部署到Nexus私服上 -->
  <distributionManagement>
    <repository>
        <id>nexus-releases</id>
        <name>Nexus ReleaseRepository</name>    
        <url>http://172.19.201.155:8081/repository/maven-releases/</url>
    </repository>
    <snapshotRepository>
        <id>nexus-snapshots</id>
        <name>Nexus SnapshotsRepository</name>      
        <url>http://172.19.201.155:8081/repository/maven-snapshots/</url>
    </snapshotRepository>
  </distributionManagement>
</project>

c.提交代码到github上
修改了代码则需要将变动信息提交到github上,操作步骤参考上面。

d.再次构建任务成功

  • 因为配置任务的时候配置了【每隔15分钟轮询源码库,如果发现有更新的时候构建本项目】和【发现github上有变化时构建本项目】,所以我这次没有手动构建,让jenkins通过构建触发器来自动构建项目。

  • 构建成功后任务的console输出

Started by an SCM change
Building in workspace C:\Windows\system32\config\systemprofile\.jenkins\workspace\helloword
 > D:\Soft\git\Git\bin\git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > D:\Soft\git\Git\bin\git.exe config remote.origin.url https://github.com/zlcook/cidemo.git # timeout=10
Fetching upstream changes from https://github.com/zlcook/cidemo.git
 > D:\Soft\git\Git\bin\git.exe --version # timeout=10
using GIT_SSH to set credentials 
 > D:\Soft\git\Git\bin\git.exe fetch --tags --progress https://github.com/zlcook/cidemo.git +refs/heads/*:refs/remotes/origin/*
 > D:\Soft\git\Git\bin\git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
 > D:\Soft\git\Git\bin\git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision ae2a6a18ebfd933e4fa81c3f7f691d8fb870a240 (refs/remotes/origin/master)
 > D:\Soft\git\Git\bin\git.exe config core.sparsecheckout # timeout=10
 > D:\Soft\git\Git\bin\git.exe checkout -f ae2a6a18ebfd933e4fa81c3f7f691d8fb870a240
 > D:\Soft\git\Git\bin\git.exe rev-list 15e935f15d8ac3190d7423eb5132b2e847a518ee # timeout=10
[helloword] $ cmd.exe /C "D:\Soft\maven\apache-maven-3.3.3\bin\mvn.cmd -s D:\Soft\maven\apache-maven-3.3.3\conf\settings.xml clean deploy && exit %%ERRORLEVEL%%"
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building maven helloword project 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ helloword ---
[INFO] Deleting C:\Windows\System32\config\systemprofile\.jenkins\workspace\helloword\target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ helloword ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Windows\System32\config\systemprofile\.jenkins\workspace\helloword\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ helloword ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Windows\System32\config\systemprofile\.jenkins\workspace\helloword\target\classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ helloword ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Windows\System32\config\systemprofile\.jenkins\workspace\helloword\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ helloword ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Windows\System32\config\systemprofile\.jenkins\workspace\helloword\target\test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ helloword ---
[INFO] Surefire report directory: C:\Windows\System32\config\systemprofile\.jenkins\workspace\helloword\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.zlcook.studymvn.helloword.HelloWordTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.038 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ helloword ---
[INFO] Building jar: C:\Windows\System32\config\systemprofile\.jenkins\workspace\helloword\target\helloword-0.0.1-SNAPSHOT.jar
[INFO] 
[INFO] --- maven-shade-plugin:2.4.3:shade (default) @ helloword ---
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing C:\Windows\System32\config\systemprofile\.jenkins\workspace\helloword\target\helloword-0.0.1-SNAPSHOT.jar with C:\Windows\System32\config\systemprofile\.jenkins\workspace\helloword\target\helloword-0.0.1-SNAPSHOT-shaded.jar
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ helloword ---
[INFO] Installing C:\Windows\System32\config\systemprofile\.jenkins\workspace\helloword\target\helloword-0.0.1-SNAPSHOT.jar to D:\Soft\maven\maven_jar\repository\com\zlcook\studymvn\helloword\0.0.1-SNAPSHOT\helloword-0.0.1-SNAPSHOT.jar
[INFO] Installing C:\Windows\System32\config\systemprofile\.jenkins\workspace\helloword\pom.xml to D:\Soft\maven\maven_jar\repository\com\zlcook\studymvn\helloword\0.0.1-SNAPSHOT\helloword-0.0.1-SNAPSHOT.pom
[INFO] 
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ helloword ---
Downloading: http://172.19.201.155:8081/repository/maven-snapshots/com/zlcook/studymvn/helloword/0.0.1-SNAPSHOT/maven-metadata.xml
778/778 B   
            
Downloaded: http://172.19.201.155:8081/repository/maven-snapshots/com/zlcook/studymvn/helloword/0.0.1-SNAPSHOT/maven-metadata.xml (778 B at 2.4 KB/sec)
Uploading: http://172.19.201.155:8081/repository/maven-snapshots/com/zlcook/studymvn/helloword/0.0.1-SNAPSHOT/helloword-0.0.1-20161201.015626-2.jar
2/4 KB      
4/4 KB   
         
Uploaded: http://172.19.201.155:8081/repository/maven-snapshots/com/zlcook/studymvn/helloword/0.0.1-SNAPSHOT/helloword-0.0.1-20161201.015626-2.jar (4 KB at 28.1 KB/sec)
Uploading: http://172.19.201.155:8081/repository/maven-snapshots/com/zlcook/studymvn/helloword/0.0.1-SNAPSHOT/helloword-0.0.1-20161201.015626-2.pom
2/3 KB   
3/3 KB   
         
Uploaded: http://172.19.201.155:8081/repository/maven-snapshots/com/zlcook/studymvn/helloword/0.0.1-SNAPSHOT/helloword-0.0.1-20161201.015626-2.pom (3 KB at 21.7 KB/sec)
Downloading: http://172.19.201.155:8081/repository/maven-snapshots/com/zlcook/studymvn/helloword/maven-metadata.xml
288/288 B   
            
Downloaded: http://172.19.201.155:8081/repository/maven-snapshots/com/zlcook/studymvn/helloword/maven-metadata.xml (288 B at 5.6 KB/sec)
Uploading: http://172.19.201.155:8081/repository/maven-snapshots/com/zlcook/studymvn/helloword/0.0.1-SNAPSHOT/maven-metadata.xml
778/778 B   
            
Uploaded: http://172.19.201.155:8081/repository/maven-snapshots/com/zlcook/studymvn/helloword/0.0.1-SNAPSHOT/maven-metadata.xml (778 B at 7.4 KB/sec)
Uploading: http://172.19.201.155:8081/repository/maven-snapshots/com/zlcook/studymvn/helloword/maven-metadata.xml
288/288 B   
            
Uploaded: http://172.19.201.155:8081/repository/maven-snapshots/com/zlcook/studymvn/helloword/maven-metadata.xml (288 B at 2.8 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.865 s
[INFO] Finished at: 2016-12-01T09:56:27+08:00
[INFO] Final Memory: 20M/198M
[INFO] ------------------------------------------------------------------------
Finished: SUCCESS

下一个demo

cidemo项目不是一个javaEE项目,目前没有涉及到tomcat,后面会做一个javaEE项目,通过持续集成把项目自动部署到tomcat上。当然在这之前我要学会编写shell脚本。

总结

这篇文章没有写持续集成的邮件反馈,一个项目在持续集成过程中如果出错了,这个错误信息要及时反馈给项目经理及造成这次错误的开发人员,以便尽快修复。下一篇文章我会介绍maven---11配置jenkins的邮件反馈

留言

有什么不懂的一起探讨一下吧,欢迎留下宝贵意见,喜欢就点个赞吧(哈哈),多谢鼓励。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 158,560评论 4 361
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,104评论 1 291
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,297评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,869评论 0 204
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,275评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,563评论 1 216
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,833评论 2 312
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,543评论 0 197
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,245评论 1 241
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,512评论 2 244
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,011评论 1 258
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,359评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,006评论 3 235
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,062评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,825评论 0 194
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,590评论 2 273
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,501评论 2 268

推荐阅读更多精彩内容