Commit f39959d0 authored by Tomasz Maczukin's avatar Tomasz Maczukin

Add some fixes to builds API

parent b5fef34f
......@@ -15,23 +15,15 @@ module API
# GET /projects/:id/builds
get ':id/builds' do
all_builds = user_project.builds
builds = all_builds.order('created_at DESC')
builds = all_builds.order('id DESC')
builds =
case params[:scope]
when 'all'
builds
when 'finished'
builds.finished
when 'running'
builds.running
when 'pending'
builds.pending
when 'success'
builds.success
when 'failed'
builds.failed
else
builds.running_or_pending.reverse_order
builds
end
page = (params[:page] || 1).to_i
......@@ -59,15 +51,14 @@ module API
# Example Request:
# GET /projects/:id/build/:build_id/trace
get ':id/builds/:build_id/trace' do
trace = get_build(params[:build_id]).trace
trace =
unless trace.nil?
trace.split("\n")
else
[]
end
build = get_build(params[:build_id])
header 'Content-Disposition', "infile; filename=\"#{build.id}.log\""
content_type 'text/plain'
env['api.format'] = :binary
present trace
trace = build.trace
body trace
end
end
......
......@@ -367,14 +367,30 @@ module API
expose :id, :variables
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
expose :id
expose :status
expose :stage
expose :name
expose :ref
expose :commit
expose :runner
expose :commit, with: CiCommit
expose :runner, with: CiRunner
expose :created_at
expose :started_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