`CI_ENVIRONMENT_SLUG` not defined when deploying some time after pipeline creation
Summary
In our Gitlab Premium On Premise instance (currently 15.3, but we've seen it earlier too) we constantly encounter problem with deploying to test environment. When running deployment job the next day after pipeline was created, we get "CI_ENVIRONMENT_SLUG
not defined" error. This is not the only variable missing - it seems like all CI_ENVIRONMENT_*
are not available.
Steps to reproduce
Our scenario is like this:
- developer pushes branch and creates MR
- pipeline is created
- Docker image build is run automatically, then QA jobs are run using built image
At this point pipeline pauses.
In the next stage, we have build jobs with when: manual
, but they are not always triggered. Sometimes we don't need it at all (when changing code that does not have impact on the app, like docs), sometimes it's triggered after some time (for example by tester who wants to check it). We also don't want to deploy automatically because:
- we have 2 separate build jobs since it's possible to deploy the app in 2 modes
- we have many parallel MRs and it wouldn't be good for our k8s cluster if every MR would create 2 large environments
Example Project
n/a
What is the current bug behavior?
In scenario, when someone wants to deploy app some time after pipeline was created (e.g. the next day), we get "CI_ENVIRONMENT_SLUG
not defined". Then we need to trigger whole new pipeline, which takes much longer, and uses much more resources because all QA jobs have to be run again.
This is wasting our time and reasources, and causes Testers Team headache
PS. According to the docs, CI_ENVIRONMENT_SLUG
should be available when environment:name
is set, and it's set in those particular jobs.
What is the expected correct behavior?
All CI_ENVIRONMENT_*
variables should be available in the deploy job, even if:
- there are multiple environments (multiple jobs with different
environment
definition) - those jobs have
when: manual
- deploy job is triggered after some time
Relevant logs and/or screenshots
Missing info in the job itself:
Debug inside deploy job:
bash-5.1# printenv | grep CI_ | head -n5
CI_PROJECT_NAMESPACE=[proprietary]
CI_RUNNER_VERSION=15.3.0
CI_MERGE_REQUEST_TARGET_BRANCH_PROTECTED=true
CI_SERVER_NAME=GitLab
CI_RUNNER_DESCRIPTION=kubernetes-ci
bash-5.1# printenv | grep CI_ENVIRONMENT
bash-5.1#
CI_ENVIRONMENT_SLUG
missing in Slack message:
Results of GitLab environment info / application Check
I don't have access to the instance, I can't gather this information.