Multiple Jobs Launched

Hi,

Recently I’ve noticed my android builds periodically fail - it launches 5 jobs, and usually in 2 or 3 of the jobs, the tests will pass, but in the rest they’ll fail. Sometimes only 1 of them pass. Here’s an example screenshot:

(Side note, it’s also unclear to me as to why there are 5 jobs - the output from each is exactly the same?)

My travis config is the following:

language: android
sudo: required
jdk: oraclejdk8

env:
  - ANDROID_API_LEVEL=28
  - ANDROID_BUILD_TOOLS_VERSION=28.0.3
  - ANDROID_ABI=armeabi-v7a
  - TEST_EMULATOR_TARGET_ANDROID_API="android-24"
  - TEST_EMULATOR_SYS_IMAGE="sys-img-armeabi-v7a-android-24"

android:
  components:
    - tools
    - platform-tools
    - tools # Appears twice per Travis docs (to update the tools)
    - build-tools-$ANDROID_BUILD_TOOLS_VERSION
    - android-$ANDROID_API_LEVEL
    - $TEST_EMULATOR_TARGET_ANDROID_API
    - extra-android-support
    - extra-android-m2repository
    - $TEST_EMULATOR_SYS_IMAGE
  licenses:
    - 'android-sdk-preview-license-52d11cd2'
    - 'android-sdk-license-.+'
    - 'google-gdk-license-.+'

before_cache:
  # Do not cache a few Gradle files/directories (see https://docs.travis-ci.com/user/languages/java/#Caching)
  - rm -f  $HOME/.gradle/caches/modules-2/modules-2.lock
  - rm -fr $HOME/.gradle/caches/*/plugin-resolution/

before_install:
  - yes | sdkmanager "platforms;android-28"
  - yes | sdkmanager "build-tools;28.0.3"

cache:
  directories:
    # Android SDK
    - $HOME/android-sdk-dl
    - $HOME/android-sdk

    # Gradle dependencies
    - $HOME/.gradle/caches/
    - $HOME/.gradle/wrapper/

    # Android build cache (see http://tools.android.com/tech-docs/build-cache)
    - $HOME/.android/build-cache

# Emulator Management: Create, Start and Wait
before_script:
  # Update sdk platform for emulator
  - echo "y" | android update sdk -a --no-ui --filter "android-24"
  # Update the emulator sys image
  - echo "y" | android update sdk -a --no-ui --filter "sys-img-armeabi-v7a-android-24"
  # Creating and waiting for emulator to run tests
  - echo no | android create avd --force -n test -t "android-24" --abi "armeabi-v7a" -c 100M
  - QEMU_AUDIO_DRV=none emulator -avd test -no-window &
  - android-wait-for-emulator
  - adb shell input keyevent 82 &

script:
  - ./gradlew clean testRelease
  - ./gradlew connectedAndroidTest
  - ./gradlew checkstyle lintRelease
  - ./gradlew ktlint

Sorry, hit send too soon - for more context

  • it’s always the ./gradlew clean testRelease component that fails in CI
  • it usually succeeds locally, but sometimes when I switch branches without cleaning or quitting and restarting android studio, it fails locally as well.

I wonder if this means it’s some sort of caching issue - should I not be caching anything at all?

Thanks!

Okay, turns out the tests failing was a specific issue with my tests :slight_smile:
So the only mystery that remains is why multiple jobs are launched at the same time, when there should only be one job

env:
  - <etc>

should be

env:
  global:
    - <etc>

https://docs.travis-ci.com/user/environment-variables/#global-variables

1 Like