blob: e7a9009f8f43481480e29d4b811d6b16f5779c4f (
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
|
# frozen_string_literal: true
module Gitlab
module Ci
module Pipeline
module Chain
class PopulateMetadata < Chain::Base
include Chain::Helpers
def perform!
set_pipeline_name
return if pipeline.pipeline_metadata.nil? || pipeline.pipeline_metadata.valid?
message = pipeline.pipeline_metadata.errors.full_messages.join(', ')
error("Failed to build pipeline metadata! #{message}")
end
def break?
pipeline.pipeline_metadata&.errors&.any?
end
private
def set_pipeline_name
return if @command.yaml_processor_result.workflow_name.blank?
name = @command.yaml_processor_result.workflow_name
name = ExpandVariables.expand(name, -> { global_context.variables.sort_and_expand_all })
return if name.blank?
pipeline.build_pipeline_metadata(project: pipeline.project, name: name.strip)
end
def global_context
Gitlab::Ci::Build::Context::Global.new(
pipeline, yaml_variables: @command.pipeline_seed.root_variables)
end
end
end
end
end
end
|