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: d19a25198036fb4f09c4c318972b45cc85d9c4b0 (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
37
38
39
40
41
42
43
44
45
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}")
          ensure
            if pipeline.builds.where(stage_id: nil).any?
              invalid_builds_counter.increment(node: hostname)
            end
          end

          def break?
            !pipeline.persisted?
          end

          private

          def invalid_builds_counter
            @counter ||= Gitlab::Metrics
              .counter(:gitlab_ci_invalid_builds_total,
                       'Invalid builds without stage assigned counter')
          end

          def hostname
            @hostname ||= Socket.gethostname
          end
        end
      end
    end
  end
end