gitlab-org--gitlab-foss/app/services/ci/create_trigger_request_service.rb

23 lines
559 B
Ruby
Raw Normal View History

2015-08-25 21:42:46 -04:00
module Ci
class CreateTriggerRequestService
def execute(project, trigger, ref, variables = nil)
2015-12-04 06:55:23 -05:00
commit = project.commit(ref)
2015-10-05 08:31:51 -04:00
return unless commit
2015-08-25 21:42:46 -04:00
2015-10-05 07:37:50 -04:00
# check if ref is tag
2015-12-04 06:55:23 -05:00
tag = project.repository.find_tag(ref).present?
2015-10-05 08:31:51 -04:00
pipeline = project.pipelines.create(sha: commit.sha, ref: ref, tag: tag)
2015-10-05 07:37:50 -04:00
2015-08-25 21:42:46 -04:00
trigger_request = trigger.trigger_requests.create!(
variables: variables,
pipeline: pipeline,
2015-08-25 21:42:46 -04:00
)
if pipeline.create_builds(nil, trigger_request)
2015-08-25 21:42:46 -04:00
trigger_request
end
end
end
end