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

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

    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分多钟.

    原文链接;http://www.cnblogs.com/laoli0201

  • 相关阅读:
    AirtestIDE基本功能(二)
    AirtestIDE基本功能(一)
    Pycharm Debug功能详解
    AirtestIDE环境安装
    leetcode-338. 比特位计数
    leetcode-401. 二进制手表
    leetcode-392. 判断子序列
    leetcode-155. 最小栈
    leetcode-111. 二叉树的最小深度
    leetcode-110. 平衡二叉树
  • 原文地址:https://www.cnblogs.com/poptest/p/4913712.html
Copyright © 2011-2022 走看看