By Wouter Donders, wo 17 mei 2023, in category Blog
Using our open-source Python application
glabvars, you can retrieve GitLab CI/CD variables and output
gitlab-ci-local YAML configuration for running GitLab CI/CD pipelines on your local development machine.
Developing software on the open-core DevOps platform GitLab often involves setting up Continuous Integration (CI) and Continuous Deployment (CD) pipelines for automating the process of delivering quality software. To run automation tasks, these CI/CD pipelines make use of built-in CI/CD variables defined by GitLab and custom CI/CD variables defined by the pipeline maintainers. Custom CI/CD variables typically contain required information for deployment targets such as deployment account names, settings, etc. Setting up these pipelines can be tricky, because they will be run on GitLab runners and not on your local machine. Iteration on CI/CD pipelines can therefore be slow and annoying.
Third-party tools like
gitlab-ci-local enable you to run GitLab CI pipelines locally.
This allows much faster iteration on developing CI pipelines.
gitlab-ci-local cannot directly access your custom GitLab CI/CD variables and inject them into local pipeline jobs.
To inject them, you must pass them explicitly through
--variable options or specify them in a YAML configuration file.
Specifying and keeping up to date the YAML configuration takes effort and is error-prone.
That's why we developed
glabvars, a Python wrapper around
glab for obtaining GitLab CI variables.
glabvars you can retrieve all project-defined CI/CD variables and output a
gitlab-ci-local YAML configuration file for CI/CD variables.
You can install
pip install glabvars
or, for better isolation of dependencies, using
pipx install glabvars
Retrieve GitLab CI/CD variables associated with your project and format them as a
gitlab-ci-local configuration file for CI/CD variables:
# Requires `glab` to be installed and authenticated with the project's GitLab instance # Must be run inside a git repository with remotes on the project's GitLab instance glabvars --target gcl
glabvars to work, you must have the GitLab CLI
glab installed and authenticated with the GitLab instance your project is tracked on.
gitlab-ci-local is not a requirement for
glabvars itself to work, it is a requirement for running GitLab CI/CD pipelines on your local machine.
Read more on GitLab's documentation: