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

Commit3e8562d

Browse files
feat(objects): add Project CI Lint support
Add support for validating a project's CI configuration [1]TODO: Add tests[1]https://docs.gitlab.com/ee/api/lint.html#validate-a-projects-ci-configuration
1 parent09b3b22 commit3e8562d

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

‎docs/gl_objects/projects.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,29 @@ Get total fetches in last 30 days of a project::
784784

785785
total_fetches = project.additionalstatistics.get().fetches['total']
786786

787+
Project CI Lint
788+
=============================
789+
790+
Reference
791+
---------
792+
793+
* v4 API:
794+
795+
+:class:`gitlab.v4.objects.ProjectCiLint`
796+
+:class:`gitlab.v4.objects.ProjectCiLintManager`
797+
+:attr:`gitlab.v4.objects.Project.ci_lint`
798+
799+
* GitLab API: https://docs.gitlab.com/ee/api/lint.html#validate-a-projects-ci-configuration
800+
801+
Examples
802+
---------
803+
804+
Validate a project's CI configuration::
805+
806+
lint_result = project.ci_lint.get()
807+
assert lint_result.valid is True # Test that the .gitlab-ci.yml is valid
808+
print(lint_result.merged_yaml) # Print the merged YAML file
809+
787810
Project storage
788811
=============================
789812

‎gitlab/v4/objects/projects.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""
2+
GitLab API:
3+
https://docs.gitlab.com/ee/api/projects.html
4+
https://docs.gitlab.com/ee/api/lint.html#validate-a-projects-ci-configuration
5+
"""
16
fromtypingimportAny,Callable,cast,Dict,List,Optional,TYPE_CHECKING,Union
27

38
importrequests
@@ -83,6 +88,8 @@
8388
"ProjectRemoteMirrorManager",
8489
"ProjectStorage",
8590
"ProjectStorageManager",
91+
"ProjectCiLint",
92+
"ProjectCiLintManager",
8693
]
8794

8895

@@ -144,6 +151,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
144151
badges:ProjectBadgeManager
145152
boards:ProjectBoardManager
146153
branches:ProjectBranchManager
154+
ci_lint:"ProjectCiLintManager"
147155
clusters:ProjectClusterManager
148156
commits:ProjectCommitManager
149157
customattributes:ProjectCustomAttributeManager
@@ -1032,3 +1040,27 @@ def get(
10321040
self,id:Optional[Union[int,str]]=None,**kwargs:Any
10331041
)->Optional[ProjectStorage]:
10341042
returncast(Optional[ProjectStorage],super().get(id=id,**kwargs))
1043+
1044+
1045+
classProjectCiLint(RESTObject):
1046+
pass
1047+
1048+
1049+
classProjectCiLintManager(GetWithoutIdMixin,RESTManager):
1050+
_path="/projects/{project_id}/ci/lint"
1051+
_obj_cls=ProjectCiLint
1052+
_from_parent_attrs= {"project_id":"id"}
1053+
# https://docs.gitlab.com/ee/api/lint.html#validate-a-projects-ci-configuration
1054+
1055+
defget(
1056+
self,id:Optional[Union[int,str]]=None,**kwargs:Any
1057+
)->Optional[ProjectCiLint]:
1058+
ifidisnotNone:
1059+
raiseAttributeError("Unsupported attribute: id")
1060+
1061+
ifTYPE_CHECKING:
1062+
assertself.pathisnotNone
1063+
server_data=self.gitlab.http_get(self.path,**kwargs)
1064+
ifTYPE_CHECKING:
1065+
assertisinstance(server_data,dict)
1066+
returnself._obj_cls(self,server_data)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp