zoukankan      html  css  js  c++  java
  • 老李分享:持续集成学好jenkins之Git和Maven配置

    老李分享:持续集成学好jenkins之Git和Maven配置

     

      poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性能测试,测试工具开发等工作为目标。如果对课程感兴趣,请大家咨询qq:908821478

    Jenkins专用术语,请参考下面连接:

    https://wiki.jenkins-ci.org/display/JENKINS/Terminology

    1.通过Jenkins web页面添加Git plugin

    Manage Jenkins->Manage Plugins->Available中选择Git Plugin安装,

    注意要填写user name和 email地址,否则日后会碰到git tag的错误

    2.Jenkins服务器上创建Git用户所需公钥

    具体步骤参考Git server文章

    http://blog.csdn.net/sheismylife/article/details/7204345

    注意,要将最后生成的.ssh目录下的公钥和私钥文件复制到/var/lib/jenkins/.ssh目录下,否则git clone命令会报错

    3.修改jenkins目录权限

    chmod -R 777 /var/lib/jenkins

    4.通过web页面创建一个项目Test,然后设置该项目使用Git作为版本管理。

    并且设置repository路径,比如:git@S1:cml.git

    5.在build选项的pom文件指定你需要执行的pom.xml路径

    比如一个测试工程名叫client,是个maven工程,设置为client/pom.xml

    6.现在可以点击左侧的Build now进行测试

    一切OK,则没有错误日志。在Build History中可以看到测试结果,有没有错误。

    7.Email发送设置

    在Manage Jenkins->Configure System->Email Notification中,设置SMTP发送的基本信息,点击Advanced,可以填写用户名和密码。还有一个测试按钮可以用来发送测试设置是否正确。

    同时在Test项目中的Building Settings打勾选中E-mail Notification,点击右边的问号,会出现帮助文档,说明在四种情况下会发送email,填写接受email的地址,然后故意将client代码修改到不能编译通过。然后点击Build now按钮测试一下。果然收到email.

    8.检查代码更新并编译

    可以通过Poll SCM来设置定时检查编译功能

    比如*/5 * * * * 就是每隔5分钟检查一次,如果git仓库中有更新,则执行build操作。

    9.使用Maven私服加快下载速度

    参阅:http://blog.csdn.net/sheismylife/article/details/7209722

    Jenkins的.m2目录路径在:/var/lib/jenkins/.m2/

    先清空所有jar包,后创建settings.xml文件,编辑内容如下:

    <settings>

      <mirrors>

        <mirror>

          <!--This sends everything else to /public -->

          <id>nexus</id>

          <mirrorOf>*</mirrorOf>

          <url>http://S1:8081/nexus/content/groups/public</url>

        </mirror>

      </mirrors>

      <profiles>

        <profile>

          <id>nexus</id>

          <!--Enable snapshots for the built in central repo to direct -->

          <!--all requests to nexus via the mirror -->

          <repositories>

            <repository>

              <id>central</id>

              <url>http://central</url>

              <releases><enabled>true</enabled></releases>

              <snapshots><enabled>true</enabled></snapshots>

            </repository>

          </repositories>

          <pluginRepositories>

            <pluginRepository>

              <id>central</id>

              <url>http://central</url>

              <releases><enabled>true</enabled></releases>

              <snapshots><enabled>true</enabled></snapshots>

            </pluginRepository>

          </pluginRepositories>

        </profile>

      </profiles>

      <activeProfiles>

        <!--make the profile active all the time -->

        <activeProfile>nexus</activeProfile>

      </activeProfiles>

    </settings>

    现在点击build now测试一下,打开console output,看看命令行输出结果,如果发现从S1下载jar包,就正确。和不用私服的比较了一下,节省了1分多钟.

  • 相关阅读:
    如果前面的IO操作出问题了,按照我们代码的意思,不就try catch 了吗,这样的话线程就没关闭了,就会造成线程泄露。 那怎么解决这个问题呢,其实也简单,把关闭线程的方法写到finally里就可以了。
    Dataeye计算任务架构
    Mercury:唯品会全链路应用监控系统解决方案详解(含PPT)
    app 爬虫
    唯品会HDFS性能挑战和优化实践
    构建Hadoop监控共同体
    消除单点故障 flume
    时间戳 Flume's Memory Consumption
    telnet nmap netstap
    hdfs ha
  • 原文地址:https://www.cnblogs.com/poptest/p/5231686.html
Copyright © 2011-2022 走看看