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

23 lines
545 B
Ruby
Raw Normal View History

2015-09-25 12:07:36 +05:30
module Ci
class CreateTriggerRequestService
def execute(project, trigger, ref, variables = nil)
2015-12-23 02:04:40 +05:30
commit = project.commit(ref)
2015-09-25 12:07:36 +05:30
return unless commit
2015-10-24 18:46:33 +05:30
# check if ref is tag
2015-12-23 02:04:40 +05:30
tag = project.repository.find_tag(ref).present?
2015-10-24 18:46:33 +05:30
2015-12-23 02:04:40 +05:30
ci_commit = project.ensure_ci_commit(commit.sha)
2015-10-24 18:46:33 +05:30
2015-09-25 12:07:36 +05:30
trigger_request = trigger.trigger_requests.create!(
2015-10-24 18:46:33 +05:30
variables: variables,
commit: ci_commit,
2015-09-25 12:07:36 +05:30
)
2015-10-24 18:46:33 +05:30
if ci_commit.create_builds(ref, tag, nil, trigger_request)
2015-09-25 12:07:36 +05:30
trigger_request
end
end
end
end