Dynamic Parallel Execution

Hello,

We have a single android project from which we’re building 27 different apps. The backbone of these apps is more or less the same. Some features are different or enabled only on some of the brands, but overall the apps look very similar to each other.

I use environment variable to determine which customers to build for. Environment variable and configuration definition as follows:

TENANT_NAMES=‘customer1;customer2’

language: android
jdk: oraclejdk8
android:
  licenses:
    - 'android-sdk-preview-license-.+'
    - 'android-sdk-license-.+'
    - 'google-gdk-license-.+'
  components:
    - tools
    - platform-tools
    - build-tools-29.0.2
    - android-29
script:
  - |
    for TENANT_NAME in $(echo ${TENANT_NAMES} | tr ";" "\n")
    do
      echo "Build is starting for $TENANT_NAME"
      ./gradlew app:assemble${TENANT_NAME}
    done

I want to run build process in parallel to shorten the execution time. I have done this by changing the following lines and it works great. You can see details here

env:
  matrix:
    - TENANT_NAME=customer1
    - TENANT_NAME=customer2
  script:
    - |
      echo "Build is starting for $TENANT_NAME"
      ./gradlew app:assemble${TENANT_NAME}

In the next step, I added the following lines to dynamically define the customers to start build process without changing travis.yml file.

env:
  matrix:
    - for TEMP in $(echo ${TENANT_NAMES} | tr ";" "\n"); do env TENANT_NAME=$TEMP; done

But it does not work as expectation and I couldn’t find solution. Can you help please?

https://travis-ci.com/dtprotel/loyalty-android/builds/144132930

Thanks

Please specify how exactly it “does not work” and what you expect instead, and link to an affected build.

A post was split to a new topic: Make an issue template to tell users what information to include

This does not work. We have to examine the configurations and configure the jobs with the information available to us when the build request is created. Environment variables such as ${TENANT_NAMES} are defined only when the VM has been instantiated and the job has already been running; they simply cannot influence the build matrix itself.

One thing you can try is to start a small build, and configure a build matrix dynamically and issue a build request via API based on whatever criteria you have.

2 Likes
Imprint