Skip to content
Snippets Groups Projects
Commit 8d455503 authored by Tomasz Maczukin's avatar Tomasz Maczukin
Browse files

Add cancel/retry endpoints to build API

parent e7d0746d
No related branches found
No related tags found
1 merge request!2207Add builds API
Pipeline #
Loading
Loading
@@ -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
Loading
Loading
@@ -81,6 +117,10 @@ module API
builds
end
end
def authorize_manage_builds!
authorize! :manage_builds, user_project
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment