Using Build Matrix for multiple Ubuntu distributions

I’m trying to test some scripts on multiple Ubuntu distributions such as Xenial, Bionic, Focal, etc. There are 5 tests to be run on each distribution, and currently using Xenial & Bionic, so 5*2=10 jobs. After adding another distribution, it would increase to 15 jobs.

Currently, each of the 10 jobs is being specified separately, so 10 entries, and I would need to add 5. That didn’t look very clean to me (even though would need to do that once) and making any change would require changing it in multiple jobs. Therefore I’m trying to use a Build Matrix to reduce all this. This is my current travis.yml

language: python
python: 3.7
os: linux

# Build Matrix for Travis
  - xenial
  - bionic
  - focal

# Scripts to be tested
  - CIINSTALL=yes SCRIPT=12   # BasicSetup + GenSoftware
  - CIINSTALL=yes SCRIPT=3    # ML-Basic
  - CIINSTALL=yes SCRIPT=4    # Build-OpenCV
  - CIINSTALL=yes SCRIPT=14   # BasicSetup + OpenCV (Conda OpenCV)
  - CIINSTALL=yes SCRIPT=5    # BuildML

  # BasicSetup + GenSoftware
  - if [[ $SCRIPT -eq 12 ]]; then
      export PATH=/opt/anaconda3/bin:$PATH;
      hash -r;

  # ML-Basic
  - if [[ $SCRIPT -eq 3 ]]; then

  # Build-OpenCV
  - if [[ $SCRIPT -eq 4 ]]; then
      ffmpeg -version;
      gdb --ex='set confirm on' -ex=run -ex=bt -ex=quit --args python3 extras/;

  # BasicSetup + OpenCV (Conda OpenCV)
  - if [[ $SCRIPT -eq 14 ]]; then
      export PATH=/opt/anaconda3/bin:$PATH;
      hash -r;
      ffmpeg -version;
      gdb --ex='set confirm on' -ex=run -ex=bt -ex=quit --args python extras/;

  # BuildML
  - if [[ $SCRIPT -eq 5 ]]; then

    - sudo add-apt-repository "deb $(lsb_release -sc) main universe restricted multiverse"
    - sudo apt-get update -qq
    - sudo apt-get install -y software-properties-common
    - sudo apt-get install -qq build-essential curl g++ python3-dev python3-setuptools gdb
    - echo 'America/Los_Angeles' | sudo tee /etc/timezone
    - sudo dpkg-reconfigure --frontend noninteractive tzdata

What I was hoping for - 3 dist * 5 env = 15 jobs
However, I’m getting only 5 jobs - For the xenial distribution only (
My commit - (Earlier use of 10 jobs an be seen in this)

Is there any way to use multiple distributions in a build matrix? I searched but didn’t find any such example.

I’m not very experienced in using Travis, and this is my first time posting here, so please let me know if any more details are required, etc.