summaryrefslogtreecommitdiff
path: root/lib/api/jobs.rb
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2017-03-06 16:56:05 +0100
committerToon Claes <toon@gitlab.com>2017-03-07 23:45:32 +0100
commitf37240067301548a41a6257792d3926b68328e62 (patch)
treed2431c67709859073f3db667fefd8e3f37586637 /lib/api/jobs.rb
parent7f2819b778b055278a7fafe9c782d12d09dbd2ea (diff)
downloadgitlab-ce-f37240067301548a41a6257792d3926b68328e62.tar.gz
Add GET /projects/:id/pipelines/:pipeline_id/jobs endpoint
Add endpoint to get the jobs scoped to a pipeline.
Diffstat (limited to 'lib/api/jobs.rb')
-rw-r--r--lib/api/jobs.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/api/jobs.rb b/lib/api/jobs.rb
index 33c05e8aa63..af8f4b1e759 100644
--- a/lib/api/jobs.rb
+++ b/lib/api/jobs.rb
@@ -40,6 +40,23 @@ module API
user_can_download_artifacts: can?(current_user, :read_build, user_project)
end
+ desc 'Get pipeline jobs' do
+ success Entities::Job
+ end
+ params do
+ requires :pipeline_id, type: Integer, desc: 'The pipeline ID'
+ use :optional_scope
+ use :pagination
+ end
+ get ':id/pipelines/:pipeline_id/jobs' do
+ pipeline = user_project.pipelines.find(params[:pipeline_id])
+ builds = pipeline.builds
+ builds = filter_builds(builds, params[:scope])
+
+ present paginate(builds), with: Entities::Job,
+ user_can_download_artifacts: can?(current_user, :read_build, user_project)
+ end
+
desc 'Get a specific job of a project' do
success Entities::Job
end