2017-04-12 05:46:24 -04:00
|
|
|
module Ci
|
|
|
|
class PlayBuildService < ::BaseService
|
|
|
|
def execute(build)
|
2017-05-05 06:25:24 -04:00
|
|
|
unless can?(current_user, :update_build, build)
|
2017-04-12 05:46:24 -04:00
|
|
|
raise Gitlab::Access::AccessDeniedError
|
|
|
|
end
|
|
|
|
|
2017-05-03 06:32:39 -04:00
|
|
|
# Try to enqueue the build, otherwise create a duplicate.
|
2017-04-12 05:46:24 -04:00
|
|
|
#
|
|
|
|
if build.enqueue
|
|
|
|
build.tap { |action| action.update(user: current_user) }
|
|
|
|
else
|
|
|
|
Ci::Build.retry(build, current_user)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|