Welcome to mirror list, hosted at ThFree Co, Russian Federation.

create_trigger_request_service.rb « ci « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1e629cf119aa5120997d1dbfa892b741c38deb1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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?

      pipeline = project.pipelines.create(sha: commit.sha, ref: ref, tag: tag)

      trigger_request = trigger.trigger_requests.create!(
        variables: variables,
        pipeline: pipeline,
      )

      if pipeline.create_builds(nil, trigger_request)
        trigger_request
      end
    end
  end
end