Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Q&D python for command line to validate .gitlab-ci.yml
#! /usr/bin/python
#
# script to validate .gitlab-ci.yml
#
import sys
import requests
import json
def main():
r = requests.post("https://gitlab.example.com/api/v4/ci/lint", json={ 'content': file(sys.argv[1], 'r').read() })
if r.status_code != requests.codes['OK']:
sys.exit(3)
data = r.json()
if data['status'] != 'valid':
for e in data['errors']:
print >> sys.stderr, e
sys.exit(1)
sys.exit(0) # valid
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.