Skip to content

Commit 463cedc

Browse files
authored
Merge pull request #785 from agustinhenze/add-pipeline-get-variables-endpoint
Add new endpoint to get the variables of a pipeline
2 parents 5af0b52 + 564de48 commit 463cedc

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

docs/gl_objects/builds.rst

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ Get a pipeline for a project::
2929

3030
pipeline = project.pipelines.get(pipeline_id)
3131

32+
Get variables of a pipeline::
33+
34+
variables = pipeline.variables.list()
35+
3236
Create a pipeline for a particular reference::
3337

3438
pipeline = project.pipelines.create({'ref': 'master'})

gitlab/v4/objects.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -3100,8 +3100,21 @@ class ProjectPipelineJobManager(ListMixin, RESTManager):
31003100
_list_filters = ("scope",)
31013101

31023102

3103+
class ProjectPipelineVariable(RESTObject):
3104+
_id_attr = "key"
3105+
3106+
3107+
class ProjectPipelineVariableManager(ListMixin, RESTManager):
3108+
_path = "/projects/%(project_id)s/pipelines/%(pipeline_id)s/variables"
3109+
_obj_cls = ProjectPipelineVariable
3110+
_from_parent_attrs = {"project_id": "project_id", "pipeline_id": "id"}
3111+
3112+
31033113
class ProjectPipeline(RESTObject, RefreshMixin, ObjectDeleteMixin):
3104-
_managers = (("jobs", "ProjectPipelineJobManager"),)
3114+
_managers = (
3115+
("jobs", "ProjectPipelineJobManager"),
3116+
("variables", "ProjectPipelineVariableManager"),
3117+
)
31053118

31063119
@cli.register_custom_action("ProjectPipeline")
31073120
@exc.on_http_error(exc.GitlabPipelineCancelError)

0 commit comments

Comments
 (0)