Managing and Storing Data, Variables, and Secrets
Project Variables, Group Variables, and Instance Variables
In GitLab, you can set variables, whether they are secret or not, at the project, group, instance level, pipeline, or job level.
We have seen how to set a project-level variable. To set a group-level variable, go to Group -> Settings -> CI/CD -> Variables. These variables are available to all projects in the group. To set an instance-level variable, go to Admin Area -> Settings -> CI/CD -> Variables. These variables are available to all projects in the GitLab instance.
ℹ️ Instance-level variables are not available on all GitLab offerings (e.g., GitLab.com).
You can also set variables at the pipeline level or the job level in the .gitlab-ci.yml file.
Use the following code to create a .gitlab-ci.yml file that defines a pipeline variable and a job variable:
cat <$HOME/todo/app/.gitlab-ci.yml && \
cd $HOME/todo/app && \
git add . && \
git commit -m "Add pipeline and job variables" && \
git push origin main
image: python:3.12
variables:
# Define a global variable
PIPELINE_VARIABLE: "I'm the pipeline variable"
stages:
- test-variables
test-1:
variables:Cloud Native CI/CD with GitLab
From Commit to Production ReadyEnroll now to unlock all content and receive all future updates for free.
