You need to install js-yaml-cli first :
npm install -g js-yaml-cli
Example :
> ./check_gitlab_ci.sh
{"status":"invalid","errors":["variables config should be a hash of key value pairs"]}%
You need to install js-yaml-cli first :
npm install -g js-yaml-cli
Example :
> ./check_gitlab_ci.sh
{"status":"invalid","errors":["variables config should be a hash of key value pairs"]}%
#!/usr/bin/env bash | |
CONTENT=$(cat .gitlab-ci.yml | yaml2json | tr -d '\n' | python -c 'import json,sys; print(json.dumps(sys.stdin.read()))') | |
curl --header "Content-Type: application/json" https://gitlab.com/api/v4/ci/lint --data "{\"content\": $CONTENT}" |
Or you could use https://github.com/Code0x58/gitlab-ci-validate (no additional dependencies) - I'll give it some polish at some point, but it does the trick at the moment
Nice, thanks for this. I had some troubles with
yaml2json
and since I don't like gists, I made a repo inspired by this gist and dockerized it so it's easy to use in a ci:https://github.com/gableroux/ansible-docker-image
✌️