firecow / gitlab-ci-local

Tired of pushing to test your .gitlab-ci.yml?
MIT License
2.05k stars 118 forks source link

Only single dotenv file supported #1160

Closed martinjuhasz closed 2 months ago

martinjuhasz commented 3 months ago

Minimal .gitlab-ci.yml illustrating the issue

build-job-single:
  stage: build
  script:
    - echo "TEST_SINGLE=true" > single.env
  artifacts:
    reports:
      dotenv: single.env
test-job-single:
  stage: test
  needs:
    - build-job-single
  script:
    - |
      if [ "$TEST_SINGLE" != "true" ]; then
        echo "TEST_SINGLE is not set to true"
        exit 1
      fi

build-job-multi:
  stage: build
  script:
    - echo "TEST_MULTI_1=true" > multi1.env
    - echo "TEST_MULTI_2=true" > multi2.env
  artifacts:
    reports:
      dotenv:
        - multi1.env
        - multi2.env
test-job-multi:
  stage: test
  needs:
    - build-job-multi
  script:
    - |
      if [ "$TEST_MULTI_1" != "true" ]; then
        echo "TEST_MULTI_1 is not set to true"
        exit 1
      fi
      if [ "$TEST_MULTI_2" != "true" ]; then
        echo "TEST_MULTI_2 is not set to true"
        exit 1
      fi

Expected behavior test-job-multi should not fail

Host information Ubuntu gitlab-ci-local 4.47.0

Additional context While dotenv artifacts are supported, it will only work if a single dotenv file is present. once dotenv contains an array of files, environment variables will not be loaded in dependend jobs.