Skip to main content

gcil

Release Python Downloads License
Build Bugs Code Smells Coverage Lines of Code Quality Gate Status
pre-commit Commitizen friendly gcil mise guidelines pre-commit-crocodile

Launch .gitlab-ci.yml jobs locally, wrapped inside the specific images,
with inplace project volume mounts and adaptive user selections

Documentation: https://radiandevcore.gitlab.io/tools/gcil
Package: https://pypi.org/project/gitlabci-local/


Purpose

The main purpose of this project is to unify and enhance reliability
of builds, tests or releases running on GitLab CI in a similar local context,
by providing the simplicity of an interactive and automated terminal tool
and avoiding code duplication (Makefile, Shell scripts, docker run, ...).

Rather than creating yet another standard, the .gitlab-ci.yml specification
is the common and unique interface between GitLab CI and gcil.


Preview

preview.svg


Examples

gcil                   # Launch the jobs choices interactive menu
gcil -p                # Launch the jobs pipeline automatically
gcil -l                # Launch the job selection interactive menu
gcil 'Dev'             # Launch jobs where the name contains a given string
gcil --debug 'Job 1'   # Hold a finishing specific job for debugging
gcil --bash 'Job 1'    # Prepare a bash environment for a specific job
gitlabci-local         # Shortcut alias to gcil

Usage

usage: gcil [-h] [--version] [--no-color] [--update-check] [--settings] [--set GROUP KEY VAL] [-p] [-q]
            [-c CONFIGURATION] [-B] [-A] [-C COMMANDS] [-n NETWORK] [-e ENV] [-E ENGINE] [-H] [--notify]
            [--privileged [BOOL]] [--random-paths] [-r] [-S] [--ssh [SSH_USER]] [-v VOLUME] [-w WORKDIR]
            [--bash | --debug] [--display] [--shell SHELL] [--all] [--configure] [--input KEY=VAL] [-f] [-i] [-m]
            [--no-console] [--no-git-safeties] [--no-script-fail] [-R] [--no-verbose] [--scripts] [-t TAGS]
            [-d | -s | -l | --pull | --rmi] [--]
            [names ...]

gcil: Launch .gitlab-ci.yml jobs locally (aliases: gitlabci-local)

internal arguments:
  -h, --help           # Show this help message
  --version            # Show the current version
  --no-color           # Disable colors outputs with 'NO_COLOR=1'
                       # (or default settings: [themes] > no_color)
  --update-check       # Check for newer package updates
  --settings           # Show the current settings path and contents
  --set GROUP KEY VAL  # Set settings specific 'VAL' value to [GROUP] > KEY
                       # or unset by using 'UNSET' as 'VAL'

pipeline arguments:
  -p, --pipeline       # Automatically run pipeline stages rather than jobs
  -q, --quiet          # Hide jobs execution context
  -c CONFIGURATION     # Path to the .gitlab-ci.yml configuration file or folder
  -B, --no-before      # Disable before_script executions
  -A, --no-after       # Disable after_script executions
  -C COMMANDS          # Run specific commands instead of "scripts" commands
  -n NETWORK           # Configure the network mode used (or define CI_LOCAL_NETWORK)
                       # Choices: bridge, host, none. Default: bridge
  -e ENV               # Define VARIABLE=value, pass VARIABLE or ENV file
  -E ENGINE            # Force a specific engine (or define CI_LOCAL_ENGINE)
                       # Default list: auto,docker,podman
  -H, --host           # Run jobs on the host rather than containers (or define CI_LOCAL_HOST)
  --notify             # Enable host notifications of pipeline and jobs results
  --privileged [BOOL]  # Give extended privileges to the containers
                       # (Defaults to 'true', or define CI_LOCAL_PRIVILEGED)
  --random-paths       # Mount random folder paths in the container
  -r, --real-paths     # Mount real folder paths in the container (Linux / macOS only)
  -S, --sockets        # Mount engine sockets for nested containers
                       # (Enabled by default with services: docker:*dind)
  --ssh [SSH_USER]     # Bind SSH credentials to a container's user
  -v VOLUME            # Mount VOLUME or HOST:TARGET in containers
  -w WORKDIR           # Override the container's working path

debugging arguments:
  --bash               # Prepare runners for manual bash purposes
  --debug              # Keep runners active for debugging purposes
  --display            # Enable host DISPLAY forwarding features
  --shell SHELL        # Configure the default bash/debug shell entrypoint

jobs arguments:
  --all                # Enable all jobs by default in selections
  --configure          # Show interactive configurations for CI/CD inputs
  --input KEY=VAL      Define KEY=value for CI/CD inputs
  -f, --force          # Force the action (use with --pull)
  -i, --ignore-case    # Ignore case when searching for names
  -m, --manual         # Allow manual jobs to be used
  --no-console         # Disable console launch in bash/debug modes
                       # (or default settings: [runner] > no_console)
  --no-git-safeties    # Disable automated Git safeties configuration
                       # (or default settings: [runner] > no_git_safeties)
  --no-script-fail     # Fail on missing 'script' nodes of jobs
                       # (or default settings: [runner] > no_script_fail)
  -R, --no-regex       # Disable regex search of names
  --no-verbose         # Hide jobs verbose outputs
  --scripts            # Dump parsed jobs entrypoint scripts
  -t TAGS              # Handle listed tags as manual jobs
                       # Default list: deploy,local,publish

features arguments:
  -d, --dump           # Dump parsed .gitlab-ci.yml configuration
  -s, --select         # Force jobs selection from enumerated names
  -l, --list           # Select one job to run (implies --manual)
  --pull               # Pull container images from jobs
  --rmi                # Delete container images from jobs

positional arguments:
  --                   # Positional arguments separator (recommended)
  names                # Names of specific jobs (or stages with --pipeline)
                       # Regex names is supported unless --no-regex is used

Additional features in 'variables'

gcil implements further support of most command-line parameters
using variables: values, either globally or specifically for each job:

variables:
  CI_LOCAL_AFTER: bool                # Enable or disable `after_script` executions (see `-A`)
  CI_LOCAL_BASH: bool                 # Prepare runners for manual bash purposes (see `--bash`)
  CI_LOCAL_BEFORE: bool               # Enable or disable `before_script` executions (see `-B`)
  CI_LOCAL_DEBUG: bool                # Keep runners active for debugging purposes (see `--debug`)
  CI_LOCAL_DISPLAY: bool              # Enable host `DISPLAY` forwarding features (see `--display`)
  CI_LOCAL_ENGINE: str                # Force a specific engine (see `-E`)
  CI_LOCAL_EXTENDS_INCOMPLETE: bool   # Accept incomplete `extends:` jobs for local use
  CI_LOCAL_HOST: bool                 # Run jobs on the host rather than containers (see `--host`)
  CI_LOCAL_MANUAL: bool               # Allow manual jobs to be used (see `--manual`)
  CI_LOCAL_NETWORK: str               # Configure the network mode used (see `--network`)
  CI_LOCAL_NO_CONSOLE: bool           # Disable console launch in bash/debug modes (see `--no-console`)
  CI_LOCAL_NO_VERBOSE: bool           # Hide jobs verbose outputs (see `--no-verbose`)
  CI_LOCAL_NOTIFY: bool               # Enable host notifications of pipeline and jobs results (see `--notify`)
  CI_LOCAL_PRIVILEGED: bool           # Configure the privileged mode used (see `--privileged`)
  CI_LOCAL_QUIET: bool                # Hide jobs execution context (see `-q`)
  CI_LOCAL_RANDOM_PATHS: bool         # Mount random folder paths in the container (see `--random-paths`)
  CI_LOCAL_REAL_PATHS: bool           # Mount real folder paths in the container (see `-r`)
  CI_LOCAL_SHELL: str                 # Configure the default bash/debug shell entrypoint (see `--shell`)
  CI_LOCAL_SOCKETS: bool              # Mount engine sockets for nested containers (see `-S`)
  CI_LOCAL_SSH: bool|str              # Bind SSH credentials to a container's user (see `--ssh`)
  CI_LOCAL_WORKDIR: str               # Override the container's working path (see `-w`)

Additional features in '.local'

gcil implements further support of most command-line parameters
inside a .local: node to ease default parameters definitions.

Supported local values for a .local node are:

.local:
  all: bool              # Enable all jobs by default in selections (see `--all`)
  env: list[str]         # Define `VARIABLE=value`, pass `VARIABLE` or `ENV` file (see `-e`)
  image: dict|str        # Override container image's `name` and/or `entrypoint
  include: dict          # Map `include: project:` names to local paths
  names: list[str]       # Names of specific jobs (or stages with `--pipeline`) (see `names`)
  no_regex: bool         # Disable regex search of names (see `--no-regex`)
  pipeline: bool         # Automatically run pipeline stages rather than jobs (see `-p`)
  tags: list[str]        # Handle listed tags as manual jobs (see `--tags`)
  variables: dict[str]   # Define `KEY: VALUE` variables for local jobs
  version: str           # Define a minimum version for `gcil` recommended for this file
  volumes: dict[str]     # Mount `VOLUME` or `HOST:TARGET` in containers (see `-v`)

Examples for each of these can be found in the local unit tests: tests/local and tests/includes


Job execution in native context

gcil runs every jobs in the specified container image.

For specific local purposes where the native host context is wished,
where the host tools, folders or credentials are required,
image: local can be used to run the scripts natively.

For specific purposes, the image: local:quiet variant
can be used to enable the quiet option for specific jobs.

The image: local:silent variant extends the quiet option
by also disabling the verbose script set -x line entry.

An example usage can be found in the local Changelog job: .gitlab-ci.yml


Environment variables

Expand environment variables documentation

gcil uses the variables defined in .gitlab-ci.yml
and parses the simple environment variables file named .env.

If specific environment variables are to be used in the job's container:

  • -e VARIABLE: pass an environment variable
  • -e VARIABLE=value: set a variable to a specific value
  • -e ENVIRONMENT_FILE: parse a file as default variables

For example, -e TERM=ansi may enable colored terminal outputs.

The variable CI_LOCAL is automatically defined to true by gcil
to allow specific conditions for local purposes in jobs' scripts.

The variable CI_LOCAL_HOST is automatically defined to true by gcil
if running the job natively on the host (for example wiht --host)

The following variables are also defined by gcil:

  • CI_COMMIT_REF_NAME: The branch or tag name for which project is built (GitLab CI)

  • CI_COMMIT_REF_SLUG: CI_COMMIT_REF_NAME in lowercase, shortened to 63 bytes,
    and with everything except 0-9 and a-z replaced with -. No leading / trailing - (GitLab CI)

  • CI_COMMIT_SHA: The commit revision for which project is built (GitLab CI)

  • CI_COMMIT_SHORT_SHA: The first eight characters of CI_COMMIT_SHA (GitLab CI)

  • CI_COMMIT_TIMESTAMP: The commit timestamp for which project is built (GitLab CI)

  • CI_PROJECT_NAME: The name of the directory for the project (GitLab CI)

  • CI_PROJECT_NAMESPACE: The project namespace (username or group name) of the job (GitLab CI)

  • CI_LOCAL_USER_HOST_GID: The host user's group ID value

  • CI_LOCAL_USER_HOST_UID: The host user's user ID value

  • CI_LOCAL_USER_HOST_USERNAME: The host user's username value


Supported container engines

gcil currently supports these container engines:


Supported systems

Supported Linux systems
Engines Linux Mint, Ubuntu CentOS Others
Native (shell) ?
Docker (as user) ?
Docker (as root) ?
Podman (as user) ~ ~ ?
Podman (as root) ?
Supported macOS systems
Engines macOS (10.14, 10.15, 11.0, ...)
Native (shell)
Docker (as user) ?

Supported Windows systems
Engines Windows 10 (1909, 2004, 20H2) Others
Native (Command Prompt) ~ ?
Native (Git Bash) ?
Docker (Hyper‑V) ?
Docker (WSL 2) ?
Supported Android systems
Engines Android (7.0, 7.1, 8.0, 8.1, 9.0, 10, 11, ...)
Native (Termux)

Compatible projects

Most GitLab CI projects should work with gcil without any local-specific changes.
However, if specific configurations like credentials, caches or user rights are needed, the CI_LOCAL variable can be used.

Projects compatible with gcil can use this badge to ease things for developers, both as an indicator and a documentation shortcut button :

gcil

[![gcil](https://img.shields.io/badge/gcil-enabled-brightgreen?logo=gitlab)](https://radiandevcore.gitlab.io/tools/gcil)
<a href="https://radiandevcore.gitlab.io/tools/gcil"><img src="https://img.shields.io/badge/gcil-enabled-brightgreen?logo=gitlab" alt="gcil" style="max-width:100%;"></a>

Userspace available settings

gcil creates a settings.ini configuration file in a userspace folder.

For example, it allows to change the default engines priority ([engines] > engine),
or to disable the automated updates daily check ([updates] > enabled)

The settings.ini file location and contents can be shown with the following command:

gcil --settings

Environment available configurations

gcil uses colored for colors outputs and questionary for interactive menus.

If colors of both outputs types do not match the terminal's theme,
an environment variable NO_COLOR=1 can be defined to disable colors.


Dependencies


References

Release files for gitlabci-local 13.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gitlabci-local 13.2.0
File Size Uploaded
gitlabci_local-13.2.0.tar.gz 227.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gitlabci-local 13.2.0
File Interpreter ABI Platform
gitlabci_local-13.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 308.5 kB

Release files / gitlabci_local-13.2.0.tar.gz

Download URL gitlabci_local-13.2.0.tar.gz
Size 227.9 kB
Tags Source
SHA-256 checksum
How to use checksums
83d70d1bc4e010c3be296bc66a1d70effbd78325e519d02d741932dab293fadc
BLAKE2b-256 checksum
How to use checksums
e44f209d92b49740add7d4141b5ccd1c6c63ed95a2dd0357b44d791954620620
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / gitlabci_local-13.2.0-py3-none-any.whl

Download URL gitlabci_local-13.2.0-py3-none-any.whl
Size 80.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
54668e118d9baf59295ce733990bed554b2ec96a90e7d6ab4ae31148b0cd692a
BLAKE2b-256 checksum
How to use checksums
1aca5ed67203891063ffd60e5849dfd88d0eee81f9a3251a9f9561a7b17e4169
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

This release

13.2.0 This release

2 release files

13.1.0

2 release files

13.0.2

2 release files

13.0.1

2 release files

13.0.0

2 release files

11.1.0

2 release files

11.0.0

2 release files

10.2.0

2 release files

10.1.0

2 release files

10.0.1

2 release files

10.0.0

2 release files

9.1.0

2 release files

9.0.0

1 release file

8.1.0

1 release file

8.0.0

1 release file

7.2.0

1 release file

7.1.0

1 release file

7.0.1

1 release file

7.0.0

1 release file

6.0.0

1 release file

5.5.0

1 release file

5.4.1

1 release file

5.4.0

1 release file

5.3.0

1 release file

5.2.0

1 release file

5.1.0

1 release file

5.0.0

1 release file

4.8.1

1 release file

4.8.0

1 release file

4.7.3

1 release file

4.7.2

1 release file

4.7.1

1 release file

4.7.0

1 release file

4.6.2

1 release file

4.6.1

1 release file

4.6.0

1 release file

4.5.2

1 release file

4.5.1

1 release file

4.5.0

1 release file

4.4.0

1 release file

4.3.0

1 release file

4.2.0

1 release file

4.1.3

1 release file

4.1.2

1 release file

4.1.1

1 release file

4.1.0

1 release file

4.0.0

1 release file

3.1.2

1 release file

3.1.1

1 release file

3.1.0

1 release file

3.0.2

1 release file

3.0.1

1 release file

3.0.0

1 release file

2.3.0

1 release file

2.2.3

1 release file

2.2.2

1 release file

2.2.1

1 release file

2.2.0

1 release file

2.1.2

1 release file

2.1.1

1 release file

2.1.0

1 release file

2.0.1

1 release file

2.0.0

1 release file

1.3.1

1 release file

1.3.0

1 release file

1.2.1

1 release file

1.2.0

1 release file

1.1.6

1 release file

1.1.5

1 release file

1.1.4

1 release file

1.1.3

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page