Intro
CI/CD Fundamentals
git-vars package
Role Based Access Control
Protected Branches and Tags
Security Templates
Artifact Management
4. Protected Variables
As recommended before, GitLab allows you to mark certain secret variables as “protected.” The Protected variables are allowed only to be used by the pipelines that run on protected branches or protected tags , adding an extra layer of security.
- Protected Variables: Only available in protected branches or tags, and their values are masked in job logs.
To mark a variable as protected:
- Navigate to your project in GitLab.
- Go to
Settings
>CI/CD
. - Expand the
Variables
section. - Click on
Add variable
. - Enter the
Key
andValue
for the variable.- We will create a variable for this example:
- Key:
PROTECTED_VAR
- Value:
ThisIsProtectedValue
- Key:
- We will create a variable for this example:
- Set the scope of the variable (Project-Level or Group-Level).
- Mark the variable as
Protected
. - Click
Add variable
to save the protected variable.
*Note: Alternatively, GitLab has HashiCorp Vault integration for secure secret management.