debian-mirror-gitlab/app/services/ci/play_build_service.rb

20 lines
552 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
module Ci
class PlayBuildService < ::BaseService
2019-10-12 21:52:04 +05:30
def execute(build, job_variables_attributes = nil)
2017-08-17 22:00:37 +05:30
unless can?(current_user, :update_build, build)
raise Gitlab::Access::AccessDeniedError
end
# Try to enqueue the build, otherwise create a duplicate.
#
if build.enqueue
2019-10-12 21:52:04 +05:30
build.tap { |action| action.update(user: current_user, job_variables_attributes: job_variables_attributes || []) }
2017-08-17 22:00:37 +05:30
else
Ci::Build.retry(build, current_user)
end
end
end
end