blob: cceaa52de16d432a35244eeeeaff4bd3d22666f8 (
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
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# frozen_string_literal: true
module Gitlab
module Ci
module Pipeline
module Chain
class EvaluateWorkflowRules < Chain::Base
include ::Gitlab::Utils::StrongMemoize
include Chain::Helpers
def perform!
@command.workflow_rules_result = workflow_rules_result
error('Pipeline filtered out by workflow rules.') unless workflow_passed?
end
def break?
@pipeline.errors.any? || @pipeline.persisted?
end
private
def workflow_passed?
workflow_rules_result.pass?
end
def workflow_rules_result
strong_memoize(:workflow_rules_result) do
workflow_rules.evaluate(@pipeline, global_context)
end
end
def workflow_rules
Gitlab::Ci::Build::Rules.new(
workflow_rules_config, default_when: 'always')
end
def global_context
Gitlab::Ci::Build::Context::Global.new(
@pipeline, yaml_variables: @command.yaml_processor_result.root_variables)
end
def has_workflow_rules?
workflow_rules_config.present?
end
def workflow_rules_config
strong_memoize(:workflow_rules_config) do
@command.yaml_processor_result.workflow_rules
end
end
end
end
end
end
end
|