blob: 81f5733b2795ccfa1d7cceedf2a5165dfd768deb (
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
57
58
59
60
61
62
|
# 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!
unless feature_enabled?
if has_workflow_rules?
error("Workflow rules are disabled", config_error: true)
end
return
end
unless workflow_passed?
error('Pipeline filtered out by workflow rules.')
end
end
def break?
@pipeline.errors.any? || @pipeline.persisted?
end
private
def feature_enabled?
Feature.enabled?(:workflow_rules, @pipeline.project, default_enabled: true)
end
def workflow_passed?
strong_memoize(:workflow_passed) do
workflow_rules.evaluate(@pipeline, global_context).pass?
end
end
def workflow_rules
Gitlab::Ci::Build::Rules.new(
workflow_config[:rules], default_when: 'always')
end
def global_context
Gitlab::Ci::Build::Context::Global.new(
@pipeline, yaml_variables: workflow_config[:yaml_variables])
end
def has_workflow_rules?
workflow_config[:rules].present?
end
def workflow_config
@command.config_processor.workflow_attributes || {}
end
end
end
end
end
end
|