File tree Expand file tree Collapse file tree 5 files changed +98
-43
lines changed
Expand file tree Collapse file tree 5 files changed +98
-43
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ API examples
1313 gl_objects/branches
1414 gl_objects/clusters
1515 gl_objects/messages
16+ gl_objects/ci_lint
1617 gl_objects/commits
1718 gl_objects/deploy_keys
1819 gl_objects/deploy_tokens
Original file line number Diff line number Diff line change @@ -6,6 +6,48 @@ CLI examples
66
77 For a complete list of objects and actions available, see :doc: `/cli-objects `.
88
9+ CI Lint
10+ -------
11+
12+ Lint a CI YAML configuration from a string:
13+
14+ .. note ::
15+
16+ To see output, you will need to use the ``-v ``/``--verbose `` flag.
17+
18+ .. code-block :: console
19+
20+ $ gitlab --verbose ci-lint create --content \
21+ "---
22+ test:
23+ script:
24+ - echo hello
25+ "
26+
27+ Lint a CI YAML configuration from a file (see :ref: `cli_from_files `):
28+
29+ .. code-block :: console
30+
31+ $ gitlab --verbose ci-lint create --content @.gitlab-ci.yml
32+
33+ Lint a project's CI YAML configuration:
34+
35+ .. code-block :: console
36+
37+ $ gitlab --verbose project-ci-lint create --project-id group/my-project --content @.gitlab-ci.yml
38+
39+ Lint a project's current CI YAML configuration:
40+
41+ .. code-block :: console
42+
43+ $ gitlab --verbose project-ci-lint get --project-id group/my-project
44+
45+ Lint a project's current CI YAML configuration on a specific branch:
46+
47+ .. code-block :: console
48+
49+ $ gitlab --verbose project-ci-lint get --project-id group/my-project --ref my-branch
50+
951 Projects
1052--------
1153
Original file line number Diff line number Diff line change @@ -288,6 +288,8 @@ Example:
288288
289289 $ gitlab -o yaml -f id,permissions -g elsewhere -c /tmp/gl.cfg project list
290290
291+ .. _cli_from_files :
292+
291293Reading values from files
292294-------------------------
293295
Original file line number Diff line number Diff line change 1+ #######
2+ CI Lint
3+ #######
4+
5+ Reference
6+ ---------
7+
8+ * v4 API:
9+
10+ + :class: `gitlab.v4.objects.CiLint `
11+ + :class: `gitlab.v4.objects.CiLintManager `
12+ + :attr: `gitlab.Gitlab.ci_lint `
13+ + :class: `gitlab.v4.objects.ProjectCiLint `
14+ + :class: `gitlab.v4.objects.ProjectCiLintManager `
15+ + :attr: `gitlab.v4.objects.Project.ci_lint `
16+
17+ * GitLab API: https://docs.gitlab.com/ee/api/lint.html
18+
19+ Examples
20+ ---------
21+
22+ Validate a CI YAML configuration::
23+
24+ gitlab_ci_yml = """.api_test:
25+ rules:
26+ - if: $CI_PIPELINE_SOURCE=="merge_request_event"
27+ changes:
28+ - src/api/*
29+ deploy:
30+ extends:
31+ - .api_test
32+ rules:
33+ - when: manual
34+ allow_failure: true
35+ script:
36+ - echo "hello world"
37+ """
38+ lint_result = gl.ci_lint.create({"content": gitlab_ci_yml})
39+
40+ print(lint_result.status) # Print the status of the CI YAML
41+ print(lint_result.merged_yaml) # Print the merged YAML file
42+
43+ Validate a project's CI configuration::
44+
45+ lint_result = project.ci_lint.get()
46+ assert lint_result.valid is True # Test that the .gitlab-ci.yml is valid
47+ print(lint_result.merged_yaml) # Print the merged YAML file
48+
49+ Validate a CI YAML configuration with a namespace::
50+
51+ lint_result = project.ci_lint.create({"content": gitlab_ci_yml})
52+ assert lint_result.valid is True # Test that the .gitlab-ci.yml is valid
53+ print(lint_result.merged_yaml) # Print the merged YAML file
Original file line number Diff line number Diff line change @@ -819,49 +819,6 @@ Get total fetches in last 30 days of a project::
819819
820820 total_fetches = project.additionalstatistics.get().fetches['total']
821821
822- Project CI Lint
823- =============================
824-
825- Reference
826- ---------
827-
828- * v4 API:
829-
830- + :class: `gitlab.v4.objects.ProjectCiLint `
831- + :class: `gitlab.v4.objects.ProjectCiLintManager `
832- + :attr: `gitlab.v4.objects.Project.ci_lint `
833-
834- * GitLab API: https://docs.gitlab.com/ee/api/lint.html
835-
836- Examples
837- ---------
838-
839- Validate a project's CI configuration::
840-
841- lint_result = project.ci_lint.get()
842- assert lint_result.valid is True # Test that the .gitlab-ci.yml is valid
843- print(lint_result.merged_yaml) # Print the merged YAML file
844-
845- Validate a CI YAML configuration with a namespace::
846-
847- gitlab_ci_yml = """.api_test:
848- rules:
849- - if: $CI_PIPELINE_SOURCE=="merge_request_event"
850- changes:
851- - src/api/*
852- deploy:
853- extends:
854- - .api_test
855- rules:
856- - when: manual
857- allow_failure: true
858- script:
859- - echo "hello world"
860- """
861- lint_result = project.ci_lint.create({"content": gitlab_ci_yml})
862- assert lint_result.valid is True # Test that the .gitlab-ci.yml is valid
863- print(lint_result.merged_yaml) # Print the merged YAML file
864-
865822Project storage
866823=============================
867824
You can’t perform that action at this time.
0 commit comments