summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/pipeline/chain/create.rb
blob: 3b067ca6aceb3a4916613e079d8aeae331089f23 (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
          def perform!
            ::Ci::Pipeline.transaction do
              pipeline.save!

              if @command.seeds_block
                @command.seeds_block.call(pipeline)
              end

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

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