summaryrefslogtreecommitdiff
path: root/lib/api/v3/pipelines.rb
blob: c48cbd2b765a9e8d884793533f77b91327d579c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module API
  module V3
    class Pipelines < Grape::API
      include PaginationParams

      before { authenticate! }

      params do
        requires :id, type: String, desc: 'The project ID'
      end
      resource :projects, requirements: { id: %r{[^/]+} } do
        desc 'Get all Pipelines of the project' do
          detail 'This feature was introduced in GitLab 8.11.'
          success ::API::Entities::Pipeline
        end
        params do
          use :pagination
          optional :scope,    type: String, values: %w(running branches tags),
                              desc: 'Either running, branches, or tags'
        end
        get ':id/pipelines' do
          authorize! :read_pipeline, user_project

          pipelines = PipelinesFinder.new(user_project, scope: params[:scope]).execute
          present paginate(pipelines), with: ::API::Entities::Pipeline
        end
      end

      helpers do
        def pipeline
          @pipeline ||= user_project.pipelines.find(params[:pipeline_id])
        end
      end
    end
  end
end