Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit40b9f4d

Browse files
author
Gauvain Pocentek
committed
Add support for the gitlab CI lint API
1 parent0cc9828 commit40b9f4d

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

‎gitlab/__init__.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,29 @@ def version(self):
227227

228228
returnself._server_version,self._server_revision
229229

230+
deflint(self,content,**kwargs):
231+
"""Validate a gitlab CI configuration.
232+
233+
Args:
234+
content (txt): The .gitlab-ci.yml content
235+
**kwargs: Extra options to send to the server (e.g. sudo)
236+
237+
Raises:
238+
GitlabAuthenticationError: If authentication is not correct
239+
GitlabVerifyError: If the validation could not be done
240+
241+
Returns:
242+
tuple: (True, []) if the file is valid, (False, errors(list))
243+
otherwise
244+
"""
245+
post_data= {'content':content}
246+
try:
247+
data=self.http_post('/ci/lint',post_data=post_data,**kwargs)
248+
exceptException:
249+
raiseGitlabVerifyError
250+
251+
return (data['status']=='valid',data['errors'])
252+
230253
defmarkdown(self,text,gfm=False,project=None,**kwargs):
231254
"""Render an arbitrary Markdown document.
232255

‎tools/python_test_v4.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@
6464
# html = gl.markdown('foo')
6565
# assert('foo' in html)
6666

67+
success,errors=gl.lint('Invalid')
68+
assert(successisFalse)
69+
assert(errors)
70+
6771
# sidekiq
6872
out=gl.sidekiq.queue_metrics()
6973
assert(isinstance(out,dict))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp