zoukankan      html  css  js  c++  java
  • travis CI

    travis可对多语言持续继承,本文以nodejs 为例。 首先添加文件.travis.yml 中
    language: node_js
    node_js:
      - "6"
      - "6.1"
      - "5.11"
      - "0.6"
      - "iojs"
    版本具体的用法
    ● node latest stable Node.js release
    ● iojs latest stable io.js release
    ● 6 latest 6.x release

    在项目配置文件package.json中,添加测试脚本,由于我用的是mocha,因此添加

    "scripts": {
    "test": "mocha"
    },

    如果想让每次提交git的时候,触发持续集成,添加以下
    "repository": {
    "type": "git",
    "url": "https://github.com/ryansecret/mytest.git"
    }

    可以看到,type:git,同样可以添加其它版本工具。
    配置完成后,提交到git。在travis中可看到,build的所有过程:

    如上:是不是很清晰。
    travis的构建主要分两大步骤:1 安装所有依赖项 2 运行script 中定义的脚本,如test等。还可以添加一些具体步骤,其实一个完整build由以下构成:
    1. Install apt addons
    2. before_install
    3. install
    4. before_script
    5. script
    6. after_success or after_failure
    7. OPTIONAL before_deploy
    8. OPTIONAL deploy
    9. OPTIONAL after_deploy
    10. after_script

       

    需要注意的是before_install, install or before_script 中只要任何一个失败,整个构建就是失败。

    install:
    - wget https://protobuf.googlecode.com/files/protobuf-2.4.1.tar.gz
    - tar -xzvf protobuf-2.4.1.tar.gz
    - pushd protobuf-2.4.1 && ./configure --prefix=/usr && make && sudo make install && popd
    可以编写自己的脚本,例如在travis.yml中添加:
    install: ./install-dependencies.sh
    如果分为多个执行,用法如下:
    install:
    - bundle install --path vendor/bundle
    - npm install

    也可以跳过安装脚本:install: true


    可以指定编译的git分支:
    # blocklist
    branches:
    except:
    - legacy
    - experimental

    # safelist
    branches:
    only:
    - master
    - stable
    分支匹配可以使用正则:
    branches:
    only:
    - master
    - /^deploy-.*$/
    如果此次提交不想构建的话,那么在提交信息中添加:[skip ci]。

    自定义host,构造的时候会在/etc/hosts中添加
    addons:
    hosts:
    - travis.dev
    - joshkalderimis.com

    构建成功后就可以部署了,支持脚本部署:
    deploy:
    provider: script
    script: scripts/deploy.sh
    on:
    branch: develop
    脚本中可以是个请求,重启各个服务器上的服务。
    同样可以发布到npm上,
    deploy:
     provider: npm
     email: "YOUR_EMAIL_ADDRESS"
     api_key: "YOUR_API_KEY"

    设置只有打tag的时候进行部署:
    deploy:
    ...
    on:
    tags: true


    当编译成功或失败时,可设置一个通知:
    notifications:
    email:
    recipients:
    - one@example.com
    - other@example.com
    on_success: [always|never|change] # default: change
    on_failure: [always|never|change] # default: always
    注意的是上面email的地址是在github上注册过的,否则是收不到消息的。对主要的团队协作平台都有支持,如slack、HipChat 等。
    同时还可以设置webhook通知:

    notifications:
    webhooks:
    urls:
    - http://hooks.mydomain.com/travisci
    - http://hooks.mydomain.com/events
    on_success: [always|never|change] # default: always
    on_failure: [always|never|change] # default: always
    on_start: [always|never|change] # default: never

  • 相关阅读:
    【bug】Android版QQ浏览器广告过滤
    -_-#ueditor编辑器chrome浏览器下只能复制最后一行
    -_-#骗子
    -_-#URL区分大小写吗
    -_-#傻傻分不清楚
    -_-#【Canvas】绘制文本
    -_-#【JS Engine】
    -_-#【浏览器】
    -_-#【Canvas】导出在<canvas>元素上绘制的图像
    COGS——C 908. 校园网 || 洛谷——P 2746 [USACO5.3]校园网Network of Schools
  • 原文地址:https://www.cnblogs.com/ryansecreat/p/6170362.html
Copyright © 2011-2022 走看看