Example for dynamically setting environment not working

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

  • Close this issue

Summary

Following the example in the GitLab documentation – Set a dynamic environment URL – I can output the shell environment variable in a script, but defining environment:name with it fails.

Example Project

See https://gitlab.com/p3k/dynamic-environment-test.

What is the current bug behavior?

There are two jobs, test-1 and test-2, the latter needing the former which defines a shell environment variable via artifacts:reports:dotenv used for creating a dynamic GitLab environment.

test-2 immediately fails with the message “This job could not be executed because it would create an environment with an invalid parameter.”

See https://gitlab.com/p3k/dynamic-environment-test/-/jobs/5601850249.

What is the expected correct behavior?

test-2 should wait until test-1 has finished successfully (it is defined to need test-2!) and use the shell environment variable when defining the GitLab environment.

Relevant logs and/or screenshots

See https://gitlab.com/p3k/dynamic-environment-test/-/jobs.

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes

Edited Sep 29, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading