# Dynamic Parallel Execution

**URL:** <https://travis-ci.community/t/dynamic-parallel-execution/6833>\
**Category:** Travis CI Discussions & Feedback\
**Created:** [January 13, 2020, 11:51am UTC](https://travis-ci.community/t/dynamic-parallel-execution/6833 "2020-01-13T11:51:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dorukkangal](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/dorukkangal/32/3620_2.png) [@dorukkangal](https://travis-ci.community/u/dorukkangal)\
**Post date:** [January 13, 2020, 11:51am UTC](https://travis-ci.community/t/dynamic-parallel-execution/6833/1 "2020-01-13T11:51:27Z")

</div>

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](https://travis-ci.com/dtprotel/loyalty-android/builds/144131160)

> ```
> 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](https://travis-ci.com/dtprotel/loyalty-android/builds/144132930)

Thanks

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [January 13, 2020, 12:08pm UTC](https://travis-ci.community/t/dynamic-parallel-execution/6833/2 "2020-01-13T12:08:57Z")

</div>

[Please specify how exactly it “does not work” and what you expect instead](http://idownvotedbecau.se/itsnotworking/), and link to an affected build.

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [January 13, 2020, 5:12pm UTC](https://travis-ci.community/t/dynamic-parallel-execution/6833/3 "2020-01-13T17:12:39Z")

</div>

Split this topic on January 13, 2020, 5:12pm UTC

A post was split to a new topic: [Make an issue template to tell users what information to include](https://travis-ci.community/t/make-an-issue-template-to-tell-users-what-information-to-include/6836)

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [January 13, 2020, 1:35pm UTC](https://travis-ci.community/t/dynamic-parallel-execution/6833/4 "2020-01-13T13:35:50Z")

</div>

> [@dorukkangal](#):
>
> In the next step, I added the following lines to dynamically define the customers to start build process without changing travis.yml file.

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](https://docs.travis-ci.com/user/triggering-builds) based on whatever criteria you have.
