Validate your GitLab CI with GitLab's API endpoint.
Project description
GitLab CI lint pre-commit hook
This is a pre-commit hook that uses GitLab's /api/v4/ci/lint
linting endpoint to validate the contents of .gitlab-ci.yml
files. This is similar to how CircleCI pre-commit hooks validate that product's required configs: by uploading your config to their API.
$ gitlabci-lint --help
usage: gitlabci-lint [-h] [-c CONFIGS] [-C GITLABCI_LINT_CONFIG] [-B [BASE_URL]] [--version] [-q]
Validate your GitLab CI with GitLab's API endpoint.
options:
-h, --help show this help message and exit
-c CONFIGS, --configs CONFIGS
CI Config files to check. (default: .gitlab-ci.yml)
-C GITLABCI_LINT_CONFIG, --gitlabci-lint-config GITLABCI_LINT_CONFIG
Pass parameters via config file. Looks first at '.gitlabci-lint.toml', then '$HOME/.config/gitlabci-lint/config.toml', unless otherwise specified.
-B [BASE_URL], --base-url [BASE_URL]
Base GitLab URL. (default: https://gitlab.com/)
--version show program's version number and exit
-q, -Q, --quiet Silently fail and pass, without output, unless improperly configured. (default: False)
By default, this tool sends your configuration to https://gitlab.com, though this can be overridden (see below for an example or the help text above).
Install
pip install pre-commit-gitlabci-lint
Usage
Requirements
GitLab Lint API now requires authorization.
- Create an access token with
api
scope. - Set access token value as a
GITLAB_TOKEN
orGITLABCI_LINT_TOKEN
environment variable. - Ensure Python version available is 3.8 or later.
Warning: GitLab tokens should not be shared. If leaked they can cause significant harm. Never store tokens in a repoitory.
Example
An example .pre-commit-config.yaml
:
---
repos:
- repo: https://github.com/bjd2385/pre-commit-gitlabci-lint
rev: <latest release>
hooks:
- id: gitlabci-lint
# args: [-b, 'https://custom.gitlab.host.com']
Configuration files
No configuration file is required for use. However, if you'd rather specify settings in your repo, you may create a config file located at /root/of/repo/.gitlabci-lint.toml
, or $HOME/.config/.gitlabci-lint/config.toml
, such as the following.
[gitlabci-lint]
quiet = false
base-url = "https://gitlab.com"
configs = [ ".gitlab-ci.yml" ]
token = "$GITLAB_TOKEN"
Development
Install dependencies by running ./scripts/dependencies.sh
. Or, if you already have yarn
in your path, yarn install:deps
.
Releases
Update setup.py/version
-string and tag this repo's master branch with the same version string (prefixed by 'v
.)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pre-commit-gitlabci-lint-1.2.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98cc95488394a629b04ef415fc846d306c1cdf2d7d2459bfb4303c7c363b8ef3 |
|
MD5 | de96e0a1766471428781c8d3c02f5398 |
|
BLAKE2b-256 | 57ec0cbbd7fdcf4f5014bc3504ce28decc00fd1461a58810377d9605bd467978 |
Hashes for pre_commit_gitlabci_lint-1.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 759ba4a6384afa7e138fcc73532071bbd933ae4231e7a4d40e2ca5eba003ba79 |
|
MD5 | 61cc2141ac3e3b248b1470645999bbce |
|
BLAKE2b-256 | dae9d92d80abc38f7791719609fef5eac46a4fbaf92f744fdf205ce721353db3 |