@slee24 Many thanks, appreciated. I hope it helps…
Since the time of asking this question, I have developed and released a Ruby gem, served on rubygems.org. Details of the gem are available from here.
gem install gitlab-lint-client
Usage for the CLI is:
The source code is available from here. The repository also serves a pre-commit hook rule called validate-gitlab-ci. Add a .pre-commit-config.yml file to the root of a repository and copy and paste the following into it:
- repo: https://github.com/dcs3spp/validate-gitlab-ci
- id: validate-gitlab-ci
args: [--yaml=.gitlab-ci.yml, --base-url=https://gitlab.com]
pip install pre-commit
Request the pre-commit tool to download and configure the git hook:
Optionally, explictly try the hook with:
pre-commit run validate-gitlab-ci --all-files
Upon first use this will configure a ruby environment and install the git pre-commit hook. Initially, this may take a few minutes but once installed the environment is reused.
From within a test repository, try it out by editing the .gitlab-ci.yml to have some invalid content. Then, try commiting the invalid .gitlab-ci.yml file. The commit should be rejected, preventing it from being pushed to the repository and breaking the CI build!