Skip to content

Commit

Permalink
Merge pull request #785 from agustinhenze/add-pipeline-get-variables-…
Browse files Browse the repository at this point in the history
…endpoint

Add new endpoint to get the variables of a pipeline
  • Loading branch information
max-wittig committed Jun 10, 2019
2 parents 5af0b52 + 564de48 commit 463cedc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/gl_objects/builds.rst
Expand Up @@ -29,6 +29,10 @@ Get a pipeline for a project::

pipeline = project.pipelines.get(pipeline_id)

Get variables of a pipeline::

variables = pipeline.variables.list()

Create a pipeline for a particular reference::

pipeline = project.pipelines.create({'ref': 'master'})
Expand Down
15 changes: 14 additions & 1 deletion gitlab/v4/objects.py
Expand Up @@ -3100,8 +3100,21 @@ class ProjectPipelineJobManager(ListMixin, RESTManager):
_list_filters = ("scope",)


class ProjectPipelineVariable(RESTObject):
_id_attr = "key"


class ProjectPipelineVariableManager(ListMixin, RESTManager):
_path = "/projects/%(project_id)s/pipelines/%(pipeline_id)s/variables"
_obj_cls = ProjectPipelineVariable
_from_parent_attrs = {"project_id": "project_id", "pipeline_id": "id"}


class ProjectPipeline(RESTObject, RefreshMixin, ObjectDeleteMixin):
_managers = (("jobs", "ProjectPipelineJobManager"),)
_managers = (
("jobs", "ProjectPipelineJobManager"),
("variables", "ProjectPipelineVariableManager"),
)

@cli.register_custom_action("ProjectPipeline")
@exc.on_http_error(exc.GitlabPipelineCancelError)
Expand Down

0 comments on commit 463cedc

Please sign in to comment.