Using user defined environment variables with dynamic Environments or multi-project pipelines

Hi,

I want to use environment variables that are dynamically defined by a pipeline job and shared between jobs using artifacts:reports:dotenv. This works fine, I can see and use those variables on script: sections but I have noticed that they cannot be used with some other sections, like environment: from the Environments and trigger: from multi-project pipelines features. When I use one of the predefined CI variables those two features work as expected, for example when declaring an environment:

deploy_app:
  stage: deploy
  environment:
    name: feature/${CI_COMMIT_REF_NAME}
    url: https://${CI_ENVIRONMENT_SLUG}-app.domain.com
    on_stop: stop_app

works, but if I use a user defined variable they don’t work:

deploy_app:
  stage: deploy
  environment:
    name: aws/${APP_ENVIRONMENT}
    url: ${APP_URL}
    on_stop: stop_app

so it seems as if user defined environment variables are not visible to those keywords. Is this expected ? if yes, is there a way to work around it ?

We are using hosted gitlab.com with our own runners (version 13.12.0).

Thanks in advance.

I did some testing and could not have the name read from a dotenv file. Appears that only the URL can be set that way.

stages:
- stage01

job01:
  stage: stage01
  script:
    - echo "DYNAMIC_ENV_URL=http://dynamictestenvironment1" >> deploy.env
  environment:
    # Name cannot be dynamically set from file
    name: $CI_PIPELINE_ID # can use CI + other vars
    # URL can be dynamically set from file
    url: $DYNAMIC_ENV_URL
  artifacts:
    reports:
      dotenv: deploy.env