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

create.rb « chain « pipeline « ci « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 02493c7fe0240a2024a24cdeed2ff1bfde89ab8d (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
30
31
32
33
34
35
36
module Gitlab
  module Ci
    module Pipeline
      module Chain
        class Create < Chain::Base
          include Chain::Helpers

          # rubocop: disable CodeReuse/ActiveRecord
          def perform!
            ::Ci::Pipeline.transaction do
              pipeline.save!

              ##
              # Create environments before the pipeline starts.
              #
              pipeline.builds.each do |build|
                if build.has_environment?
                  project.environments.find_or_create_by(
                    name: build.expanded_environment_name
                  )
                end
              end
            end
          rescue ActiveRecord::RecordInvalid => e
            error("Failed to persist the pipeline: #{e}")
          end
          # rubocop: enable CodeReuse/ActiveRecord

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