2019-12-26 22:10:19 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
module Pipeline
|
|
|
|
module Chain
|
|
|
|
module Config
|
|
|
|
class Process < Chain::Base
|
|
|
|
include Chain::Helpers
|
|
|
|
|
|
|
|
def perform!
|
|
|
|
raise ArgumentError, 'missing config content' unless @command.config_content
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
result = logger.instrument(:pipeline_config_process, once: true) do
|
2022-01-26 12:08:38 +05:30
|
|
|
processor = ::Gitlab::Ci::YamlProcessor.new(
|
|
|
|
@command.config_content, {
|
|
|
|
project: project,
|
|
|
|
pipeline: @pipeline,
|
|
|
|
sha: @pipeline.sha,
|
|
|
|
source: @pipeline.source,
|
|
|
|
user: current_user,
|
|
|
|
parent_pipeline: parent_pipeline,
|
2023-05-27 22:25:52 +05:30
|
|
|
pipeline_config: @command.pipeline_config,
|
2022-01-26 12:08:38 +05:30
|
|
|
logger: logger
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
processor.execute
|
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
|
|
|
|
add_warnings_to_pipeline(result.warnings)
|
2020-07-28 23:09:34 +05:30
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
if result.valid?
|
|
|
|
@command.yaml_processor_result = result
|
|
|
|
else
|
|
|
|
error(result.errors.first, config_error: true)
|
|
|
|
end
|
2020-07-28 23:09:34 +05:30
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
@pipeline.config_metadata = result.config_metadata
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
rescue StandardError => ex
|
2020-01-01 13:55:28 +05:30
|
|
|
Gitlab::ErrorTracking.track_exception(ex,
|
2019-12-26 22:10:19 +05:30
|
|
|
project_id: project.id,
|
|
|
|
sha: @pipeline.sha
|
2020-01-01 13:55:28 +05:30
|
|
|
)
|
2019-12-26 22:10:19 +05:30
|
|
|
|
|
|
|
error("Undefined error (#{Labkit::Correlation::CorrelationId.current_id})",
|
|
|
|
config_error: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
def break?
|
|
|
|
@pipeline.errors.any? || @pipeline.persisted?
|
|
|
|
end
|
2020-07-28 23:09:34 +05:30
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def add_warnings_to_pipeline(warnings)
|
|
|
|
return unless warnings.present?
|
|
|
|
|
|
|
|
warnings.each { |message| warning(message) }
|
|
|
|
end
|
2019-12-26 22:10:19 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|