Expose job tags from .gitlab-ci.yml as predefined variable
Proposal
Currently, GitLab CI/CD provides the $CI_RUNNER_TAGS
predefined variable which contains the tags assigned to the runner executing a job.
However, there is no way to access the tags
that are explicitly defined in the .gitlab-ci.yml
file for a specific job.
This feature request proposes adding a new predefined variable (e.g., $CI_JOB_TAGS
) that would contain the tags specified in the job definition within the CI/CD YAML configuration.
This was requested by one of our customers where they need to monitor the tag usage based on the job.
Example:
We have a runner that has the tags [docker, production]
deploy:
tags:
- docker
script:
- echo "Job tags: $CI_JOB_TAGS" # shows "docker"
- echo "Runner tags: $CI_RUNNER_TAGS" # shows "docker, production"