gitlab-org--gitlab-foss/app/services/ci/play_build_service.rb
Matija Čupić a5aa40c5fe Add Job specific variables
Adds Job specific variables to facilitate specifying variables when
running manual jobs.
2019-07-29 07:43:10 +00:00

19 lines
552 B
Ruby

# frozen_string_literal: true
module Ci
class PlayBuildService < ::BaseService
def execute(build, job_variables_attributes = nil)
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, job_variables_attributes: job_variables_attributes || []) }
else
Ci::Build.retry(build, current_user)
end
end
end
end