2015-12-21 78 views
1

我正在構建腳本作爲我的特拉維斯生成過程的一部分:搖籃任務失敗,但特拉維斯建還通過

sudo: false 
env: 
    global: 
language: android 
jdk: 
- oraclejdk8 
android: 
    components: 
    ... 
before_install: 
    ... 
script: 
- ./scripts/build.sh 

我跑了一些搖籃任務build.sh腳本的一部分:

... 
./gradlew clean assembleDebug testDebug -PdisablePreDex 
... 

testDebug是因爲不通過的測試失敗:

2 tests completed, 1 failed 
:MyApp:testDebugUnitTest FAILED 
FAILURE: Build failed with an exception. 
* What went wrong: 
Execution failed for task ':MyApp:testDebugUnitTest'. 
> There were failing tests. See the report at: file:///home/travis/build.../build/reports/tests/debug/index.html 
* Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 

的問題是,特拉維斯構建仍然是成功的。我認爲任何失敗的Gradle任務都會導致Travis構建失敗。我想這不是這種情況。我如何確保任何失敗的Gradle任務都無法通過Travis構建?

[更新]

如果我直接將命令的gradle進入travis.yml文件,然後一切工作像它應該。

sudo: false 
env: 
    global: 
language: android 
jdk: 
- oraclejdk8 
android: 
    components: 
    ...  
before_install: 
    ... 
script: ./gradlew clean assembleDebug testDebug -PdisablePreDex 

回答

3

問題是我沒有通過Gradle行的退出碼從我的腳本中傳回Travis。

當我檢查shell腳本退出碼並傳回給特拉維斯一切都很好:

... 
./gradlew clean assembleDebug testDebug -PdisablePreDex 
if [ $? != 0 ] 
then 
exit $? 
fi 

... # continue doing other stuff