tscheppe
tscheppe

Reputation: 698

Gitlab Ci include local only executes last

I got a lot of different android flavors for one app to build, so i want to split up the building into different yml files. I currently have my base file .gitlab-ci.yml

image: alvrme/alpine-android:android-29-jdk11

variables:
  GIT_SUBMODULE_STRATEGY: recursive

before_script:
    - export GRADLE_USER_HOME=`pwd`/.gradle
    - chmod +x ./gradlew
    
cache:
  key: "$CI_COMMIT_REF_NAME"
  paths:
     - .gradle/

stages:
  - test
  - staging
  - production
  - firebaseUpload
  - slack

include:
  - local: '/.gitlab/bur.yml'
  - local: '/.gitlab/vil.yml'
  - local: '/.gitlab/kom.yml'

I am currently trying to build 3 different flavors. But i dont know why only the last included yml file gets executed. the first 2 are ignored.

/.gitlab/bur.yml

unitTests:
  stage: test

  script:
    - ./gradlew testBurDevDebugUnitTest

/.gitlab/vil.yml

unitTests:
  stage: test

  script:
    - ./gradlew testVilDevDebugUnitTest

/.gitlab/kom.yml

unitTests:
  stage: test

  script:
    - ./gradlew testKomDevDebugUnitTest

Upvotes: 1

Views: 3678

Answers (1)

ErikMD
ErikMD

Reputation: 14723

What you observe looks like the expected behavior:

Your three files .gitlab/{bur,vil,kom}.yml contain the same job name unitTests.
So, each include overrides the specification of this job.
As a result, you only get 1 unitTests job in the end, with the specification from the last YAML file.

Thus, the simplest fix would be to change this job name, e.g.:

unitTests-kom:
  stage: test

  script:
    - ./gradlew testKomDevDebugUnitTest

Upvotes: 6

Related Questions