本篇作為筆記用途,記錄 Travis CI 參考資料
Script
script 來指定執行動作或測試的指令碼
1
| script: bundle exec thor build
|
若有多個冬作可以寫成這樣:
1 2 3
| script: - command1 - command2
|
請注意!script 與 install 對於失敗後的動作有不一樣的處理方式,在 script 中,如果 command1 失敗 command2 會繼續執行,但整個狀態還是失敗的。
如果 command2 只有在 command1 成功後才能執行,可以寫成這樣:
1
| script: command1 && command2
|
指令碼生命週期
完整的生命週期,從開始到結束是下面的流程:
- before_install
- install
- before_script
- script
- after success or after failure
- [OPTIONAL] before_deploy
- [OPTIONAL] deploy
- [OPTIONAL] after_deploy
- after_script
指令碼範例
REF: nukc/how-to-use-travis-ci
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| language: android
notifications: email: false
sudo: false
android: components: - tools - build-tools-23.0.2 - android-23 - extra-android-m2repository - extra-android-support
before_install: - chmod +x gradlew
script: - ./gradlew assembleRelease
before_deploy: - mv app/build/outputs/apk/app-release.apk app/build/outputs/apk/buff.apk deploy: provider: releases api_key: secure: 7f4dc45a19f742dce39cbe4d1e5852xxxxxxxxx file: app/build/outputs/apk/buff.apk skip_cleanup: true on: tags: true
|
部屬到 NuGet.org
參考 Repo: adamovic-cw/travis-nuget-test
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| language: csharp sudo: false mono: - latest env: TEST_VERSION=1.0.8 solution: Travis.Nuget.Example.sln script: - /bin/sh ./build.sh - /bin/sh ./test.sh deploy: skip_cleanup: true provider: script script: - /bin/sh ./deploy.sh on: tags: true
|
1 2 3
| #!/usr/bin/env bash mono nuget.exe pack Travis.Nuget.Example/Travis.Nuget.Example.nuspec -Version $TEST_VERSION -Verbosity detailed && \ mono nuget.exe push Travis.Nuget.Example.$TEST_VERSION.nupkg -ApiKey $NUGET_API_KEY -Verbosity detailed -Source nuget.org
|
參考資料: