debian-mirror-gitlab/app/services/ci/play_build_service.rb
2021-01-30 21:13:32 +05:30

17 lines
530 B
Ruby

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