gitlab-org--gitlab-foss/app/services/ci/play_build_service.rb
2017-05-05 12:25:24 +02:00

17 lines
431 B
Ruby

module Ci
class PlayBuildService < ::BaseService
def execute(build)
unless can?(current_user, :update_build, build)
raise Gitlab::Access::AccessDeniedError
end
# Try to enqueue the build, otherwise create a duplicate.
#
if build.enqueue
build.tap { |action| action.update(user: current_user) }
else
Ci::Build.retry(build, current_user)
end
end
end
end