Commit f39959d0 authored by Tomasz Maczukin's avatar Tomasz Maczukin

Add some fixes to builds API

parent b5fef34f
...@@ -15,23 +15,15 @@ module API ...@@ -15,23 +15,15 @@ module API
# GET /projects/:id/builds # GET /projects/:id/builds
get ':id/builds' do get ':id/builds' do
all_builds = user_project.builds all_builds = user_project.builds
builds = all_builds.order('created_at DESC') builds = all_builds.order('id DESC')
builds = builds =
case params[:scope] case params[:scope]
when 'all'
builds
when 'finished' when 'finished'
builds.finished builds.finished
when 'running' when 'running'
builds.running builds.running
when 'pending'
builds.pending
when 'success'
builds.success
when 'failed'
builds.failed
else else
builds.running_or_pending.reverse_order builds
end end
page = (params[:page] || 1).to_i page = (params[:page] || 1).to_i
...@@ -59,15 +51,14 @@ module API ...@@ -59,15 +51,14 @@ module API
# Example Request: # Example Request:
# GET /projects/:id/build/:build_id/trace # GET /projects/:id/build/:build_id/trace
get ':id/builds/:build_id/trace' do get ':id/builds/:build_id/trace' do
trace = get_build(params[:build_id]).trace build = get_build(params[:build_id])
trace =
unless trace.nil? header 'Content-Disposition', "infile; filename=\"#{build.id}.log\""
trace.split("\n") content_type 'text/plain'
else env['api.format'] = :binary
[]
end
present trace trace = build.trace
body trace
end end
end end
......
...@@ -367,14 +367,30 @@ module API ...@@ -367,14 +367,30 @@ module API
expose :id, :variables expose :id, :variables
end end
class CiCommit < Grape::Entity
expose :id
expose :ref
expose :sha
expose :committed_at
end
class CiRunner < Grape::Entity
expose :id
expose :token
expose :description
expose :active
expose :is_shared
expose :name
end
class Build < Grape::Entity class Build < Grape::Entity
expose :id expose :id
expose :status expose :status
expose :stage expose :stage
expose :name expose :name
expose :ref expose :ref
expose :commit expose :commit, with: CiCommit
expose :runner expose :runner, with: CiRunner
expose :created_at expose :created_at
expose :started_at expose :started_at
expose :finished_at expose :finished_at
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment