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

23 lines
559 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
pipeline = project.pipelines.create(sha: commit.sha, ref: ref, tag: tag)
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,
pipeline: pipeline,
2015-09-25 12:07:36 +05:30
)
if pipeline.create_builds(nil, trigger_request)
2015-09-25 12:07:36 +05:30
trigger_request
end
end
end
end