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 CircleCI pre-commit hooks that validate that product's configuration files.
$ 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], -B [BASE_URL], --base-url [BASE_URL]
Base GitLab URL. (default: https://gitlab.com/)
-p PROJECT_ID, -P PROJECT_ID, --project-id PROJECT_ID
Project ID to use with the lint API.
--version show program's version number and exit
-q, -Q, --quiet Silently fail and pass, without output, unless improperly configured. (default: False)
Install
pip install pre-commit-gitlabci-lint
Usage
Setup
- Create an access token with
api
scope. - Set access token value in an environment variable named
GITLAB_TOKEN
orGITLABCI_LINT_TOKEN
. - Add the projectId for your gitlab project as a command line argument, or set it in the config file.
- Ensure the virtualenv Python version is 3.8 or later.
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', '-p', '12345678']
Use 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"
project-id = "12345678"
configs = [ ".gitlab-ci.yml" ]
token = "$GITLAB_TOKEN"
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
Close
Hashes for pre-commit-gitlabci-lint-1.3.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a9dda583d39e6f3ddd40d6687dea348f12f0305ad0bded59ca2bbe14ce3d97d |
|
MD5 | da117624bb4ed42be6da334c9e5d4509 |
|
BLAKE2b-256 | 19bcc9178d566e16c8eedd318b1f43b541999167fbb0e3d51bfe76659d99ae7e |
Close
Hashes for pre_commit_gitlabci_lint-1.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76e939c3f0f7ebaae3195dc8c79bef977b23a9a255634df7d672e6c5d225d17c |
|
MD5 | 634c09ed96535114aa3dae48340d58b1 |
|
BLAKE2b-256 | 69a503c2792762a683152ae05bd5ce2df731a29f76cb579841d09c8f2f6dbb81 |