debian-mirror-gitlab/lib/gitlab/ci/pipeline/chain/populate.rb

48 lines
1.2 KiB
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
2018-05-09 12:01:36 +05:30
module Gitlab
module Ci
module Pipeline
module Chain
class Populate < Chain::Base
include Chain::Helpers
PopulateError = Class.new(StandardError)
def perform!
2019-12-26 22:10:19 +05:30
raise ArgumentError, 'missing stage seeds' unless @command.stage_seeds
2018-05-09 12:01:36 +05:30
2019-10-12 21:52:04 +05:30
##
# Populate pipeline with all stages, and stages with builds.
#
2019-12-26 22:10:19 +05:30
pipeline.stages = @command.stage_seeds.map(&:to_resource)
2019-10-12 21:52:04 +05:30
2020-03-09 13:42:32 +05:30
if stage_names.empty?
2018-05-09 12:01:36 +05:30
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
def break?
pipeline.errors.any?
end
2020-03-09 13:42:32 +05:30
private
def stage_names
# We filter out `.pre/.post` stages, as they alone are not considered
# a complete pipeline:
# https://gitlab.com/gitlab-org/gitlab/issues/198518
pipeline.stages.map(&:name) - ::Gitlab::Ci::Config::EdgeStagesInjector::EDGES
end
2018-05-09 12:01:36 +05:30
end
end
end
end
end