Skip to content

Commit e8d2538

Browse files
JohnVillalovosnejch
authored andcommitted
feat(api): add content_ref and dry_run_ref parameters to ProjectCiLintManager
Add support for the new GitLab API parameters for validating existing CI/CD configurations: - content_ref: specify the branch, tag, or SHA to validate - dry_run_ref: set branch/tag context for dry run simulations The deprecated 'ref' parameter is kept for backward compatibility. Also update documentation with examples showing how to validate CI configuration from specific branches and with dry run simulation. Fixes python-gitlab#3260
1 parent 2982f20 commit e8d2538

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

docs/gl_objects/ci_lint.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ Lint a project's CI configuration::
4646
assert lint_result.valid is True # Test that the .gitlab-ci.yml is valid
4747
print(lint_result.merged_yaml) # Print the merged YAML file
4848

49+
Lint a project's CI configuration from a specific branch or tag::
50+
51+
lint_result = project.ci_lint.get(content_ref="main")
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
54+
55+
Lint a project's CI configuration with dry run simulation::
56+
57+
lint_result = project.ci_lint.get(dry_run=True, dry_run_ref="develop")
58+
assert lint_result.valid is True # Test that the .gitlab-ci.yml is valid
59+
print(lint_result.merged_yaml) # Print the merged YAML file
60+
4961
Lint a CI YAML configuration with a namespace::
5062

5163
lint_result = project.ci_lint.create({"content": gitlab_ci_yml})

gitlab/v4/objects/ci_lint.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,14 @@ class ProjectCiLintManager(
5151
_path = "/projects/{project_id}/ci/lint"
5252
_obj_cls = ProjectCiLint
5353
_from_parent_attrs = {"project_id": "id"}
54-
_optional_get_attrs = ("dry_run", "include_jobs", "ref")
54+
_optional_get_attrs = (
55+
"content_ref",
56+
"dry_run",
57+
"dry_run_ref",
58+
"include_jobs",
59+
"ref",
60+
)
61+
5562
_create_attrs = RequiredOptional(
5663
required=("content",), optional=("dry_run", "include_jobs", "ref")
5764
)

0 commit comments

Comments
 (0)