summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/pipeline/chain/seed_block.rb
blob: f8e62949beabc36cd790b913d9f6ce1b66128931 (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
# frozen_string_literal: true

module Gitlab
  module Ci
    module Pipeline
      module Chain
        class SeedBlock < Chain::Base
          include Chain::Helpers
          include Gitlab::Utils::StrongMemoize

          def perform!
            return unless ::Gitlab::Ci::Features.seed_block_run_before_workflow_rules_enabled?(project)

            ##
            # Populate pipeline with block argument of CreatePipelineService#execute.
            #
            @command.seeds_block&.call(pipeline)

            raise "Pipeline cannot be persisted by `seeds_block`" if pipeline.persisted?
          end

          def break?
            return false unless ::Gitlab::Ci::Features.seed_block_run_before_workflow_rules_enabled?(project)

            pipeline.errors.any?
          end
        end
      end
    end
  end
end