Dynamic environment URL

Hi support team,

I would like to use dynamic environment url as below (Refer from https://docs.gitlab.com/ee/ci/environments/). However there is no button Open live environment for the environment

review:
  script:
    - DYNAMIC_ENVIRONMENT_URL="https://$CI_COMMIT_REF_SLUG.domain.com"
    - echo "DYNAMIC_ENVIRONMENT_URL=$DYNAMIC_ENVIRONMENT_URL"
  environment:
    name: review/$CI_COMMIT_REF_SLUG
    url: $DYNAMIC_ENVIRONMENT_URL
    on_stop: stop_review

Expectation: It should enable button Open live environment for the environment with value = https://test.domain.com if $CI_COMMIT_REF_SLUG = test

Gitlab version: 12.9.4

Could you please check and give suggestion?

Thanks,
Uyen Vu

I’m no expert here, and have not done this myself yet. I am just about to set this up.
To me it looks like you’re missing the .env file. So change

  - echo "DYNAMIC_ENVIRONMENT_URL=$DYNAMIC_ENVIRONMENT_URL"

to the following:

  - echo "DYNAMIC_ENVIRONMENT_URL=$DYNAMIC_ENVIRONMENT_URL" >> deploy.env    # Add the value to a dotenv file.
artifacts:
  reports:
    dotenv: deploy.env

From Set dynamic environment URLs after a job finishes:

To use this feature, specify the artifacts:reports:dotenv keyword in .gitlab-ci.yml.

Hi @peron,

Thank you for your point. I will try it.

Thanks,
Uyen Vu