Skip to main content

gitlab_lint

This is a CLI application to quickly lint .gitlab-ci.yml files using the gitlab api. This can easily be added as a pre-commit step to locally catch any issues with your configuration prior to pushing your changes.

Installation

python3 -m pip install -U gitlab_lint

Configuration

You can set the following environmental variables:

GITLAB_LINT_DOMAIN - Which allows you to override the default gitlab.com domain, and point at a local instance

GITLAB_LINT_TOKEN - If your .gitlab-ci.yml contains any includes, you may need to set a private token to pull data from those other repos

GITLAB_LINT_PROJECT - If your .gitlab-ci.yml contains any includes which source from your local repo, you may set your project ID. If your repo is private, you must set your token as well.

GITLAB_LINT_PATH - If you're linting anything other than the default .gitlab-ci.yml file.

GITLAB_LINT_VERIFY - If you prefer TLS checking

I would recommend adding these to your ~/.profile or ~/.bash_profile

Parameters

Flag Description Type Default Required
--domain Gitlab Domain. You can set envvar GITLAB_LINT_DOMAIN string gitlab.com no
--project Gitlab Project ID. You can set envvar GITLAB_LINT_PROJECT string None no
--token Gitlab Personal Token. You can set envvar GITLAB_LINT_TOKEN string None no
--path Path to .gitlab-ci.yml, defaults to local directory. You can set envvar GITLAB_LINT_PATH string .gitlab-ci.yml no
--verify Enables HTTPS verification, which is disabled by default to support privately hosted instances. You can set envvar GITLAB_LINT_VERIFY Flag False no

Example Usage

If your .gitlab-ci.yml is in the current directory it is as easy as:

$ gll
GitLab CI configuration is valid

Failures will appear like so:

$ gll
GitLab CI configuration is invalid
(<unknown>): could not find expected ':' while scanning a simple key at line 26 column 1

If you need to you can specify the path:

$ gll --path path/to/.gitlab-ci.yml
GitLab CI configuration is valid

If you choose not to set the envvars for domain and token you can pass them in as flags:

$ gll --path path/to/.gitlab-ci.yml --domain gitlab.mycompany.com --project 1234 --token <gitlab personal token>
GitLab CI configuration is valid

Https verification is disabled by default to support privately hosted instances, if you would like to enable pass the --verify | -v flag

$ gll --verify
GitLab CI configuration is valid

Development

Bug Reports & Feature Requests

Please use the submit a issue to report any bugs or file feature requests.

Developing

If you are interested in being a contributor and want to get involved in developing this CLI application feel free to reach out

In general, PRs are welcome. We follow the typical trunk based development Git workflow.

  1. Branch the repo
  2. Clone the project to your own machine
  3. Commit changes to your branch
  4. Push your work back up to your branch
  5. Submit a Merge/Pull Request so that we can review your changes

NOTE: Be sure to merge the latest changes from "upstream" before making a pull request!

Virtual environments

This project supports Poetry for Python virtual environments. Poetry may be installed via pip, and environments can be accessed with poetry shell or poetry run.

Tests

Run tests in root directory with pytest

pre-commit

To use this with pre-commit.com, you can use something like

-   repo: https://github.com/mick352/gitlab-lint
    rev: pre-commit-hook
    hooks:
    -   id: gitlab-ci-check
        pass_filenames: false
        args: [-d, my.private.repo, -r, project_id, -t, private_token]

(or remove the args line for gitlab.com).

Metadata

Release files for gitlab-lint 0.4.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 gitlab-lint 0.4.0
File Size Uploaded
gitlab-lint-0.4.0.tar.gz 5.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gitlab-lint 0.4.0
File Interpreter ABI Platform
gitlab_lint-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.9 kB

Release files / gitlab-lint-0.4.0.tar.gz

Download URL gitlab-lint-0.4.0.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2a0203b175207cea329111751318876acb0a0a3452be76267772b22343d3b38e
BLAKE2b-256 checksum
How to use checksums
a59a38bb9db45ee125dfd63f23813ff78253c9cbdcf9aaf9577b13d630528dde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / gitlab_lint-0.4.0-py3-none-any.whl

Download URL gitlab_lint-0.4.0-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
31932e6df910d65ac26ae02d382dafa6a999993fb8cffe843dd788ebdbbd1912
BLAKE2b-256 checksum
How to use checksums
5696df6bbdbda55435de6e7200d591d33f595a746bb5c484590c1393402723ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.0

2 release files

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