gitlab-org--gitlab-foss/app/services/ci/create_trigger_request_service.rb
Kamil Trzcinski af7214d0f0 Fix specs
2016-04-11 23:32:55 +02:00

22 lines
561 B
Ruby

module Ci
class CreateTriggerRequestService
def execute(project, trigger, ref, variables = nil)
commit = project.commit(ref)
return unless commit
# check if ref is tag
tag = project.repository.find_tag(ref).present?
ci_commit = project.ci_commits.create(sha: commit.sha, ref: ref, tag: tag)
trigger_request = trigger.trigger_requests.create!(
variables: variables,
commit: ci_commit,
)
if ci_commit.create_builds(nil, trigger_request)
trigger_request
end
end
end
end