I'm running a build script as part of my Travis build process:
sudo: false
env:
global:
language: android
jdk:
- oraclejdk8
android:
components:
...
before_install:
...
script:
- ./scripts/build.sh
I'm running some Gradle tasks as part of build.sh script:
...
./gradlew clean assembleDebug testDebug -PdisablePreDex
...
testDebug is failing because of non passing test:
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.
The problem is that the Travis build is still succeeding. I thought that any failing Gradle task would fail a Travis build. I guess this isn't the case. How can I ensure that any failing Gradle task fails a Travis build?
[UPDATE]
If I move the gradle command directly into the travis.yml file then everything works like it should.
sudo: false
env:
global:
language: android
jdk:
- oraclejdk8
android:
components:
...
before_install:
...
script: ./gradlew clean assembleDebug testDebug -PdisablePreDex