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

Appearance settings

Commit bdb6d63

Browse filesBrowse files
kw217Gauvain Pocentek
authored andcommitted
Add manager for jobs within a pipeline. (python-gitlab#413)
1 parent 5149651 commit bdb6d63
Copy full SHA for bdb6d63

File tree

Expand file treeCollapse file tree

3 files changed

+36
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+36
-6
lines changed
Open diff view settings
Collapse file

‎docs/gl_objects/builds.py‎

Copy file name to clipboardExpand all lines: docs/gl_objects/builds.py
+10-2Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,18 @@
5555
builds = commit.builds()
5656
# end commit list
5757

58-
# get
58+
# pipeline list get
59+
# v4 only
60+
project = gl.projects.get(project_id)
61+
pipeline = project.pipelines.get(pipeline_id)
62+
jobs = pipeline.jobs.list() # gets all jobs in pipeline
63+
job = pipeline.jobs.get(job_id) # gets one job from pipeline
64+
# end pipeline list get
65+
66+
# get job
5967
project.builds.get(build_id) # v3
6068
project.jobs.get(job_id) # v4
61-
# end get
69+
# end get job
6270

6371
# artifacts
6472
build_or_job.artifacts()
Collapse file

‎docs/gl_objects/builds.rst‎

Copy file name to clipboardExpand all lines: docs/gl_objects/builds.rst
+14-4Lines changed: 14 additions & 4 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@ Remove a variable:
122122
Builds/Jobs
123123
===========
124124

125-
Builds/Jobs are associated to projects and commits. They provide information on
126-
the builds/jobs that have been run, and methods to manipulate them.
125+
Builds/Jobs are associated to projects, pipelines and commits. They provide
126+
information on the builds/jobs that have been run, and methods to manipulate
127+
them.
127128

128129
Reference
129130
---------
@@ -169,11 +170,20 @@ To list builds for a specific commit, create a
169170
:start-after: # commit list
170171
:end-before: # end commit list
171172

173+
To list builds for a specific pipeline or get a single job within a specific
174+
pipeline, create a
175+
:class:`~gitlab.v4.objects.ProjectPipeline` object and use its
176+
:attr:`~gitlab.v4.objects.ProjectPipeline.jobs` method (v4 only):
177+
178+
.. literalinclude:: builds.py
179+
:start-after: # pipeline list get
180+
:end-before: # end pipeline list get
181+
172182
Get a job:
173183

174184
.. literalinclude:: builds.py
175-
:start-after: # get
176-
:end-before: # end get
185+
:start-after: # get job
186+
:end-before: # end get job
177187

178188
Get a job artifact:
179189

Collapse file

‎gitlab/v4/objects.py‎

Copy file name to clipboardExpand all lines: gitlab/v4/objects.py
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,6 +1883,8 @@ def raw(self, file_path, ref, streamed=False, action=None, chunk_size=1024,
18831883

18841884

18851885
class ProjectPipeline(RESTObject):
1886+
_managers = (('jobs', 'ProjectPipelineJobManager'), )
1887+
18861888
@cli.register_custom_action('ProjectPipeline')
18871889
@exc.on_http_error(exc.GitlabPipelineCancelError)
18881890
def cancel(self, **kwargs):
@@ -1940,6 +1942,16 @@ def create(self, data, **kwargs):
19401942
return CreateMixin.create(self, data, path=path, **kwargs)
19411943

19421944

1945+
class ProjectPipelineJob(ProjectJob):
1946+
pass
1947+
1948+
1949+
class ProjectPipelineJobManager(GetFromListMixin, RESTManager):
1950+
_path = '/projects/%(project_id)s/pipelines/%(pipeline_id)s/jobs'
1951+
_obj_cls = ProjectPipelineJob
1952+
_from_parent_attrs = {'project_id': 'project_id', 'pipeline_id': 'id'}
1953+
1954+
19431955
class ProjectSnippetNoteAwardEmoji(ObjectDeleteMixin, RESTObject):
19441956
pass
19451957

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.