Class: Gitlab::Ci::Pipeline::Chain::Populate

Inherits:
Base
  • Object
show all
Includes:
Helpers
Defined in:
lib/gitlab/ci/pipeline/chain/populate.rb

Constant Summary collapse

PopulateError =
Class.new(StandardError)

Instance Attribute Summary

Attributes inherited from Base

#command, #config, #pipeline

Instance Method Summary collapse

Methods included from Helpers

#error, #persist_pipeline?, #warning

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Gitlab::Ci::Pipeline::Chain::Base

Instance Method Details

#break?Boolean

Returns:

  • (Boolean)

31
32
33
# File 'lib/gitlab/ci/pipeline/chain/populate.rb', line 31

def break?
  pipeline.errors.any?
end

#perform!Object

Raises:

  • (ArgumentError)

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gitlab/ci/pipeline/chain/populate.rb', line 12

def perform!
  raise ArgumentError, 'missing stage seeds' unless @command.stage_seeds

  ##
  # Populate pipeline with all stages, and stages with builds.
  #
  pipeline.stages = @command.stage_seeds.map(&:to_resource)

  if stage_names.empty?
    return error('No stages / jobs for this pipeline.')
  end

  if pipeline.invalid?
    return error('Failed to build the pipeline!')
  end

  raise Populate::PopulateError if pipeline.persisted?
end