summaryrefslogtreecommitdiff
path: root/gitlab
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2018-05-29 10:50:08 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2018-05-29 10:50:08 +0200
commit40b9f4d62d5b9853bfd63317d8ad578b4525e665 (patch)
tree4e9143e7a6b0313ee799295e3b4815f265066bd6 /gitlab
parent0cc9828fda25531a57010cb310f23d3c185e63a6 (diff)
downloadgitlab-40b9f4d62d5b9853bfd63317d8ad578b4525e665.tar.gz
Add support for the gitlab CI lint API
Diffstat (limited to 'gitlab')
-rw-r--r--gitlab/__init__.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py
index fd4abcf..8d522b4 100644
--- a/gitlab/__init__.py
+++ b/gitlab/__init__.py
@@ -227,6 +227,29 @@ class Gitlab(object):
return self._server_version, self._server_revision
+ def lint(self, content, **kwargs):
+ """Validate a gitlab CI configuration.
+
+ Args:
+ content (txt): The .gitlab-ci.yml content
+ **kwargs: Extra options to send to the server (e.g. sudo)
+
+ Raises:
+ GitlabAuthenticationError: If authentication is not correct
+ GitlabVerifyError: If the validation could not be done
+
+ Returns:
+ tuple: (True, []) if the file is valid, (False, errors(list))
+ otherwise
+ """
+ post_data = {'content': content}
+ try:
+ data = self.http_post('/ci/lint', post_data=post_data, **kwargs)
+ except Exception:
+ raise GitlabVerifyError
+
+ return (data['status'] == 'valid', data['errors'])
+
def markdown(self, text, gfm=False, project=None, **kwargs):
"""Render an arbitrary Markdown document.