Add cancel/retry endpoints to build API

This commit is contained in:
Tomasz Maczukin 2015-12-28 16:38:29 +01:00
parent e7d0746d93
commit 8d4555037a

View file

@ -64,6 +64,42 @@ module API
trace = build.trace
body trace
end
# cancel a specific build of a project
#
# parameters:
# id (required) - the id of a project
# build_id (required) - the id of a build
# example request:
# post /projects/:id/build/:build_id/cancel
post ':id/builds/:build_id/cancel' do
authorize_manage_builds!
build = get_build(params[:build_id])
return not_found!(build) unless build
build.cancel
present build, with: Entities::Build
end
# cancel a specific build of a project
#
# parameters:
# id (required) - the id of a project
# build_id (required) - the id of a build
# example request:
# post /projects/:id/build/:build_id/retry
post ':id/builds/:build_id/retry' do
authorize_manage_builds!
build = get_build(params[:build_id])
return not_found!(build) unless build && build.retryable?
build = Ci::Build.retry(build)
present build, with: Entities::Build
end
end
helpers do
@ -81,6 +117,10 @@ module API
builds
end
end
def authorize_manage_builds!
authorize! :manage_builds, user_project
end
end
end
end