Alex Dai Playground

Posts match “ travis-ci ” tag:

[Travis CI] Install Client

| Comments

1. 必須先安裝 ruby & RubyGems (https://github.com/travis-ci/travis.rb#installation)

2. gem install travis

P.S windows 7在安裝時發生錯誤:

bad response Not Found 404 (https://rubygems.global.ssl.fastly.net/quick/Marshal.4.8/pry-0.9.12.6-x86-mingw32.gemspec.rz),

似乎是 gem 版本的問題 (http://stackoverflow.com/questions/28835959/ruby-shoes-app-gem-chef-bad-response-not-found-404)
解決辦法: $ gem update --system 2.4.4 (退回2.4.4版)

3. repo 目錄 下執行

先建立 .travis.yml 檔案

$ touch .travis.yml

設定 git

.git/config 加入以下

[travis]
    slug = <user/org>/<repo>
設定 travis 可以 push 回 github
方法1.

#取得 GitHub Personal access tokens
Personal settings -> Personal access tokens

# 登入到 Travis

$ travis login --auto --github-token <Personal Access Token>

# Token 加密

$ travis encrypt 'GIT_NAME="your_name" GIT_EMAIL="your_email" GH_TOKEN=<Personal Access Token>' --add

P.S --add 此參數會將結果直接寫入.travis.yml

此時 .travis.yml 會出現:

env:
       global:
         secure: .... 一大串英數與符號 ....

在其他地方需使用變數時,例如 GtHub Personal Access Token

只需 $GH_TOKEN 即為 上面3-1拿到到的 Access Token

[Travis-CI] Could not find any version that matches com.android.support:support-v13:23+

| Comments

因為 ionic 使用了phonegap-plugin-push 套件

travis-ci 執行到 $ ionic build --release android

發生以下錯誤:

FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':_debugCompile'.
   > Could not find any version that matches com.android.support:support-v13:23+.
     Searched in the following locations:
         https://repo1.maven.org/maven2/com/android/support/support-v13/maven-metadata.xml
         https://repo1.maven.org/maven2/com/android/support/support-v13/
         file:/usr/local/android-sdk/extras/android/m2repository/com/android/support/support-v13/maven-metadata.xml
         file:/usr/local/android-sdk/extras/google/m2repository/com/android/support/support-v13/maven-metadata.xml
         file:/usr/local/android-sdk/extras/google/m2repository/com/android/support/support-v13/
     Required by:
         :android:unspecified
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED

解決方法:
.travis.yml add Additional components

  components:
  - extra-android-m2repository
  - extra-google-m2repository

https://github.com/travis-ci/travis-ci/issues/2470
http://docs.travis-ci.com/user/languages/android/#CI-Environment-for-Android-Projects

[npm] install 忽略 postinstall

| Comments

因為某專案時常在 travis-ci 執行到 ionic state restore 發生 timeout (10分鐘)的問題

正好 travis 有提供 travis_retry 指令可以自動重試所需執行指令
改成使用 travis_wait 延長指令執行時間

package.json
  "scripts": {
    "postinstall": "ionic state restore"
  }
.travis.yml 修改前
install:

-travis_wait npm install

跑了幾遍還是會 timeout
travis_retry npm install 似乎不包含 postinstall 所執行的指令

我需要的是
npm install 本地跑 postinstall, 而 travis-ci 不跑 postinstall

此時可以下參數, 不執行 package.json scripts 的指令
npm install --ignore-scripts

.travis.yml 修改後
install:

- npm install --ignore-scripts

- travis_wait ionic state restore