debian-mirror-gitlab/app/services/ci/play_build_service.rb
2018-11-18 11:00:15 +05:30

19 lines
462 B
Ruby

# frozen_string_literal: true
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