Skip to content

Add manager for jobs within a pipeline. - #413

Merged
gpocentek merged 3 commits into
python-gitlab:masterfrom
kw217:add-pipeline-job-manager
Jan 18, 2018
Merged

Add manager for jobs within a pipeline.#413
gpocentek merged 3 commits into
python-gitlab:masterfrom
kw217:add-pipeline-job-manager

Conversation

@kw217

@kw217 kw217 commented Jan 10, 2018

Copy link
Copy Markdown
Contributor

This PR adds a manager for jobs within a pipeline, so you can say gl.projects.get(prid).pipelines.get(plid).jobs.list() to list all of the jobs within a single pipeline (in GitLab v4).

Please let me know if there are any tests I should add. The existing UTs still pass.

@gpocentek gpocentek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this change! Could you have a look at my comments and make the suggested modifications before I merge?

If could could add a couple examples (list and get) in the documentation that would be very nice.

Thanks again 👍

Comment thread gitlab/v4/objects.py Outdated
return CreateMixin.create(self, data, path=path, **kwargs)


class ProjectPipelineJobManager(RetrieveMixin, RESTManager):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you use GetWithoutIdMixin instead of RetrieveMixin?

It looks like getting a single job is not possible with the GitLab API, but we can simulate this feature by looping through the list.

Comment thread gitlab/v4/objects.py Outdated

class ProjectPipelineJobManager(RetrieveMixin, RESTManager):
_path = '/projects/%(project_id)s/pipelines/%(pipeline_id)s/jobs'
_obj_cls = ProjectJob

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd rather use a new ProjectPipelineJob instead of ProjectJob. This is choice I made for other objects and managers, so I'd rather stick to this logic.

kw217 added 2 commits January 15, 2018 10:37
Review markup: better to use a distinct ProjectPipelineJob rather
than sharing ProjectJob. This is consistent with the other objects
and managers.
@kw217

kw217 commented Jan 15, 2018

Copy link
Copy Markdown
Contributor Author

Thanks @gpocentek - I've added some docs, distinguished the classes as you requested (I just made an pass subclass of the existing class - I hope that's what you wanted), and I've added get support via GetFromListMixin.

In principle we could implement get more efficiently by just calling ProjectJobManager.get and checking the result is in the same pipeline, but there wasn't a mixin to do this already and I wasn't sure how to get hold of the ProjectJobManager so I followed your suggestion instead.

Thanks.

@kw217

kw217 commented Jan 15, 2018

Copy link
Copy Markdown
Contributor Author

Not sure why the Python 2.7 build failed, but it looks like a connection error pulling one of the libraries, not related to my change :-(

Edit: it seems to have passed now.

@gpocentek
gpocentek merged commit bdb6d63 into python-gitlab:master Jan 18, 2018
@gpocentek

Copy link
Copy Markdown
Contributor

@kw217 Thanks!

@kw217

kw217 commented Jan 18, 2018

Copy link
Copy Markdown
Contributor Author

Great, thank you!

@kw217
kw217 deleted the add-pipeline-job-manager branch January 18, 2018 11:18
@kw217

kw217 commented Jan 22, 2018

Copy link
Copy Markdown
Contributor Author

Hi @gpocentek - when are you likely to spin a new release containing this enhancement? I'd like to use it in a tool I'm writing, and it will be simpler to point people at PyPI than getting them to download master. Thanks.

@gpocentek

Copy link
Copy Markdown
Contributor

Hi @kw217

I'd like to fix a few bugs and merge #398 before doing a release. I hope I'll have this ready in a couple weeks.

@kw217

kw217 commented Jan 24, 2018

Copy link
Copy Markdown
Contributor Author

Super - that would be great. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants