Lint .gitlab-ci.yaml
Local only linters
These don't use the /api/v4/ci/lint API endpoint
check-jsonschema
see ../../json.md
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.33.0
hooks:
- id: check-gitlab-ci
args: ["--verbose"]
Linters that use the Gitlab API
These use the /api/v4/ci/lint API endpoint. One major blocker:
CI Lint API support for passing included files in working tree
is still open, until this gets solved we can't use the Gitlab CI API with local
includes. See also
pre-commit check_yaml hook fails on gitlab-ci files
for more details.
orobardet/gitlab-ci-linter
- GitHub
- Go
- Can be used with pre-commit
- Not available in Arch-/AUR, Mise, Mason
- Install from Gitlab releases
- pre-commit-hook integration
- Setup
- Not available as Arch/AUR package, install from GitHub releases
Usage:
gitlab-ci-lint
pre-commit-gitlabci-lint
Install:
pipx install pre-commit-gitlabci-lint
- Create an access token with api scope.
- Set access token value in an environment variable named
GITLAB_TOKENorGITLABCI_LINT_TOKEN. - Add the projectId for your gitlab project as a command line argument, or set it in the config file.
- Adjust the
configuration
in
~/.config/.gitlabci-lint/config.toml
Usage:
gitlabci-lint -p <project_id>
repos:
- repo: https://github.com/bjd2385/pre-commit-gitlabci-lint
rev: v1.4.0
hooks:
- id: gitlabci-lint
# args: [-b, 'https://custom.gitlab.host.com', '-p', '12345678']
Stale / not working
- devopshq/gitlab-ci-linter
- Python
- Works as a pre-commit hook
- Last commit 2023-09, worked fine with Gitlab API \< v16, but broke with v16
- FalcoSuessgott/lint-gitlab-ci
- Bash
- Works as a pre-commit hook
- Last commit 2023-09
- kadrach/pre-commit-gitlabci-lint
- Python
- Last commit 2021-02
- smop/pre-commit-hooks
- Bash
- Last commit 2019
- BuBuaBu/gitlab-ci-lint
- Javascript
- Last commit 2021
- AUR package
nodejs-gitlab-ci-lint