summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/pipeline/chain/create.rb
blob: d5e17a123dfeb1e456ba40a8513fb7b766c84eb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
module Gitlab
  module Ci
    module Pipeline
      module Chain
        class Create < Chain::Base
          include Chain::Helpers

          def perform!
            ::Ci::Pipeline.transaction do
              pipeline.save!

              @command.seeds_block&.call(pipeline)

              ::Ci::CreatePipelineStagesService
                .new(project, current_user)
                .execute(pipeline)
            end
          rescue ActiveRecord::RecordInvalid => e
            error("Failed to persist the pipeline: #{e}")
          end

          def break?
            !pipeline.persisted?
          end
        end
      end
    end
  end
end