summaryrefslogtreecommitdiff
path: root/docs/gl_objects/ci_lint.rst
diff options
context:
space:
mode:
authorNejc Habjan <nejc.habjan@siemens.com>2022-07-09 13:56:33 +0200
committerJohn Villalovos <john@sodarock.com>2022-07-09 08:22:20 -0700
commit3b1ede4a27cd730982d4c579437c5c689a8799e5 (patch)
tree62889d73ce7a6523ff8036a6006111695fbc2894 /docs/gl_objects/ci_lint.rst
parent0daec5fa1428a56a6a927b133613e8b296248167 (diff)
downloadgitlab-3b1ede4a27cd730982d4c579437c5c689a8799e5.tar.gz
feat: support validating CI lint results
Diffstat (limited to 'docs/gl_objects/ci_lint.rst')
-rw-r--r--docs/gl_objects/ci_lint.rst22
1 files changed, 19 insertions, 3 deletions
diff --git a/docs/gl_objects/ci_lint.rst b/docs/gl_objects/ci_lint.rst
index 6533db3..ad2d875 100644
--- a/docs/gl_objects/ci_lint.rst
+++ b/docs/gl_objects/ci_lint.rst
@@ -19,7 +19,7 @@ Reference
Examples
---------
-Validate a CI YAML configuration::
+Lint a CI YAML configuration::
gitlab_ci_yml = """.api_test:
rules:
@@ -40,14 +40,30 @@ Validate a CI YAML configuration::
print(lint_result.status) # Print the status of the CI YAML
print(lint_result.merged_yaml) # Print the merged YAML file
-Validate a project's CI configuration::
+Lint a project's CI configuration::
lint_result = project.ci_lint.get()
assert lint_result.valid is True # Test that the .gitlab-ci.yml is valid
print(lint_result.merged_yaml) # Print the merged YAML file
-Validate a CI YAML configuration with a namespace::
+Lint a CI YAML configuration with a namespace::
lint_result = project.ci_lint.create({"content": gitlab_ci_yml})
assert lint_result.valid is True # Test that the .gitlab-ci.yml is valid
print(lint_result.merged_yaml) # Print the merged YAML file
+
+Validate a CI YAML configuration (raises ``GitlabCiLintError`` on failures)::
+
+ # returns None
+ gl.ci_lint.validate({"content": gitlab_ci_yml})
+
+ # raises GitlabCiLintError
+ gl.ci_lint.validate({"content": "invalid"})
+
+Validate a CI YAML configuration with a namespace::
+
+ # returns None
+ project.ci_lint.validate({"content": gitlab_ci_yml})
+
+ # raises GitlabCiLintError
+ project.ci_lint.validate({"content": "invalid"})