Getting started with GitLab: Working with CI/CD variables

Table of Contents
- Scopes of CI/CD variables
- Defining CI/CD variables
- Using CI/CD variables
- Predefined CI/CD variables
- Unlock the power of variables
1. Scopes of CI/CD variables
- Project-level variables: Specific to a single project for project-specific settings like deployment URLs.
- Group-level variables: Shared across all projects within a GitLab group for common settings like API keys for shared services or global configuration settings.
- Instance-level variables: Available to all projects on a GitLab instance for global environment settings such as default Docker image.
2. Defining CI/CD variables
- Click on the Settings > CI/CD buttons for the desired scope (project, group, instance).
- Optionally check the Mask variable box to hide the variable's value from job logs.
3. Using CI/CD variables
- Prefix the variable name with $ to use it in your file.
4. Predefined CI/CD variables
GitLab provides predefined CI/CD variables like $CI_PIPELINE_ID which represents the ID of the current pipeline.
5. Unlock the power of variables
Mastering CI/CD variables allows for more flexible, secure, and efficient workflows in GitLab pipelines.