summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTomasz Maczukin <tomasz@maczukin.pl>2015-12-28 16:38:29 +0100
committerTomasz Maczukin <tomasz@maczukin.pl>2015-12-28 16:38:29 +0100
commit8d4555037a844d21dbf56c2995cff30782af920b (patch)
treee11078909968f336d0e5092b7ac96322711d2ae7 /lib
parente7d0746d9319119c459581615ae4205139bee444 (diff)
downloadgitlab-ce-8d4555037a844d21dbf56c2995cff30782af920b.tar.gz
Add cancel/retry endpoints to build API
Diffstat (limited to 'lib')
-rw-r--r--lib/api/builds.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/api/builds.rb b/lib/api/builds.rb
index 5ac24d0367a..16e4549d280 100644
--- a/lib/api/builds.rb
+++ b/lib/api/builds.rb
@@ -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