Skip to content

add "list pipeline jobs" handler #378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions gitlab/v4/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -1707,6 +1707,10 @@ def raw(self, file_path, ref, streamed=False, action=None, chunk_size=1024,


class ProjectPipeline(RESTObject):
_managers = (
('jobs', 'PipelineJobManager'),
)

@cli.register_custom_action('ProjectPipeline')
@exc.on_http_error(exc.GitlabPipelineCancelError)
def cancel(self, **kwargs):
Expand Down Expand Up @@ -1764,6 +1768,12 @@ def create(self, data, **kwargs):
return CreateMixin.create(self, data, path=path, **kwargs)


class PipelineJobManager(ListMixin, RESTManager):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you can list and get jobs, you should use a RetrieveMixin here.

_path = '/projects/%(project_id)s/pipelines/%(pipeline_id)s/jobs'
_obj_cls = ProjectJob
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although this seems to be a good idea to use a ProjectJob, things get a bit more complicated than expected when using the CLI. To avoid bad surprises I try to stick to the upstream API logic: we are requesting a different URL so we get a different object class.

Could you create and use a PipelineJob object class instead?

_from_parent_attrs = {'project_id': 'project_id', 'pipeline_id': 'id'}


class ProjectSnippetNote(SaveMixin, ObjectDeleteMixin, RESTObject):
pass

Expand Down