Gitlab CI Lint on the Command Line#

Here’s how to lint gitlab-ci.yml using python-gitlab’s CLI.

After you installed python-gitlab, create a new profile called somewhere by editing ~/.python-gitlab.cfg and putting the following content:

[global]
default = somewhere
ssl_verify = true
timeout = 5

[somewhere]
url = https://git.example.com
private_token = xxxxxxxxxxxxxxxxxxxx
api_version = 4

Now to lint the .gitlab-ci.yml of project bar in group foo, simply run

gitlab -g somewhere --verbose project-ci-lint validate \
  --project-id foo/bar --content @.gitlab-ci.yml

Makefile for copy pasta

MAKEFLAGS += --always-make

# https://blog.hukudo.de/infra/gitlab-ci-lint-cli.html
ci-lint:
	gitlab -g somewhere --verbose project-ci-lint validate --project-id foo/bar --content @.gitlab-ci.yml