blob: 48b138b02582f3feff12c5ac68259e2b3732a7d2 (
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
|
# frozen_string_literal: true
module Gitlab
module Ci
module Build
module Context
class Build < Base
include Gitlab::Utils::StrongMemoize
attr_reader :attributes
def initialize(pipeline, attributes = {})
super(pipeline)
@attributes = attributes
end
def variables
stub_build.scoped_variables
end
strong_memoize_attr :variables
private
def stub_build
# This is a temporary piece of technical debt to allow us access
# to the CI variables to evaluate rules before we persist a Build
# with the result. We should refactor away the extra Build.new,
# but be able to get CI Variables directly from the Seed::Build.
::Ci::Build.new(build_attributes)
end
# Assigning tags and needs is slow and they are not needed for rules
# evaluation since we don't use them to compute the variables at this point.
def build_attributes
if pipeline.reduced_build_attributes_list_for_rules?
attributes
.except(:tag_list, :needs_attributes)
.merge!(pipeline_attributes, ci_stage_attributes)
else
attributes.merge(pipeline_attributes, ci_stage_attributes)
end
end
def ci_stage_attributes
{
ci_stage: ::Ci::Stage.new(
name: attributes[:stage],
position: attributes[:stage_idx],
pipeline: pipeline_attributes[:pipeline],
project: pipeline_attributes[:project]
)
}
end
end
end
end
end
end
|