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

  • 相关阅读:
    关于selenium中的sendKeys()隔几秒发送一个字符
    C#使用.net.mail配置163邮箱报错:不允许使用邮箱名称。 服务器响应为:authentication is required,smtp9,DcCowABHK4UYE11W2k6fAQ--.52196S2 1448940312
    Git一个本地仓库同时推送到多个远程仓库
    MySQL中的字符数据存储
    在IIS中启用net.tcp传输协议
    MS CRM 2016 二次开发知识点
    微软 CRM 2016 自定义视图顶部按钮
    CodeSmith7.0.2连接Oracle10.2
    使用Entity framework框架执行存储过程
    SQL建表公共字段脚本
  • 原文地址:https://www.cnblogs.com/poptest/p/4913712.html
Copyright © 2011-2022 走看看