summaryrefslogtreecommitdiff
path: root/docs/gl_objects
diff options
context:
space:
mode:
authorJohn L. Villalovos <john@sodarock.com>2022-07-04 23:21:31 -0700
committerJohn L. Villalovos <john@sodarock.com>2022-07-04 23:21:31 -0700
commitb213dd379a4108ab32181b9d3700d2526d950916 (patch)
tree40967476cd35b7cde0b48336a5d6b1f065acb3fe /docs/gl_objects
parent91c17b704f51e9a06b241d549f9a07a19c286118 (diff)
downloadgitlab-b213dd379a4108ab32181b9d3700d2526d950916.tar.gz
feat(objects): add Project CI Lint support
Add support for validating a project's CI configuration [1] [1] https://docs.gitlab.com/ee/api/lint.html
Diffstat (limited to 'docs/gl_objects')
-rw-r--r--docs/gl_objects/projects.rst43
1 files changed, 43 insertions, 0 deletions
diff --git a/docs/gl_objects/projects.rst b/docs/gl_objects/projects.rst
index b5a5d66..4c67e41 100644
--- a/docs/gl_objects/projects.rst
+++ b/docs/gl_objects/projects.rst
@@ -819,6 +819,49 @@ Get total fetches in last 30 days of a project::
total_fetches = project.additionalstatistics.get().fetches['total']
+Project CI Lint
+=============================
+
+Reference
+---------
+
+* v4 API:
+
+ + :class:`gitlab.v4.objects.ProjectCiLint`
+ + :class:`gitlab.v4.objects.ProjectCiLintManager`
+ + :attr:`gitlab.v4.objects.Project.ci_lint`
+
+* GitLab API: https://docs.gitlab.com/ee/api/lint.html
+
+Examples
+---------
+
+Validate 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::
+
+ gitlab_ci_yml = """.api_test:
+ rules:
+ - if: $CI_PIPELINE_SOURCE=="merge_request_event"
+ changes:
+ - src/api/*
+ deploy:
+ extends:
+ - .api_test
+ rules:
+ - when: manual
+ allow_failure: true
+ script:
+ - echo "hello world"
+ """
+ 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
+
Project storage
=============================