I have a pipeline that runs jobs against a number of static environments. I see that my job is marking the environment as disposable…
declare -x CI_DISPOSABLE_ENVIRONMENT="true"
What controls that, and does it affect the job execution in some way? That is output from a job like:
dev_deploy:
script:
- echo "deploy stuff"
stage: integration
environment:
deployment_tier: development
name: dev-1
action: start
Predefined variables reference | GitLab explains its purpose:
Only available if the job is executed in a disposable environment (something that is created only for this job and disposed of/destroyed after the execution - all executors except shell
and ssh
). true
when available.
I should have been a little more specific. I’ve read that, but I’d like to understand what defines an environment as disposable. Even in my environments that are marked as protected, I see the deploy jobs have: CI_DISPOSABLE_ENVIRONMENT="true"
.
1 Like
I can understand why you are confused with this. But CI_DISPOSABLE_ENVIRONMENT
is related to the job execution environment (the runner), not the environment defined in the .gitlab-ci.yml
. It basically defines if the job execution environment will be re-used over different jobs (which is only the case for shell
and ssh
executor)
1 Like
@mreardonx Sorry, I missed the linked question to deployment environments, it was a little late and my brain tired. @Taucher2003 's answer is correct, it’s an internal environment state, thus the executor environment that can either be shared/continuously used, or disposable. A container will be thrown away after execution for example, a shell environment keeps the state after job execution, e.g. from pip install
.
I was curious where the variable is coming from, and looked into the source code in common/build.go · main · GitLab.org / gitlab-runner · GitLab where the alternative variable is CI_SHARED_ENVIRONMENT
and a function called IsSharedEnv
leading to Kubernetes and more. That goes beyond my knowledge, unfortunately.
TL;DR - I don’t think that there is a user-facing benefit to using this variable, it remains internal only.
Thank you both. That makes sense. “Environment” is such a slippery term. I jumped to a conclusion I shouldn’t have.
1 Like