blob: 88b7bb89b899e1d4efcf933fcedf5f0f2c46c137 (
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
|
# frozen_string_literal: true
module Ci
##
# This module implements methods that provide context in form of
# essential CI/CD variables that can be used by a build / bridge job.
#
module Contextable
##
# Variables in the environment name scope.
#
def scoped_variables(environment: expanded_environment_name, dependencies: true)
track_duration do
pipeline
.variables_builder
.scoped_variables(self, environment: environment, dependencies: dependencies)
end
end
def track_duration
start_time = ::Gitlab::Metrics::System.monotonic_time
result = yield
duration = ::Gitlab::Metrics::System.monotonic_time - start_time
::Gitlab::Ci::Pipeline::Metrics
.pipeline_builder_scoped_variables_histogram
.observe({}, duration.seconds)
result
end
##
# Variables that do not depend on the environment name.
#
def simple_variables
strong_memoize(:simple_variables) do
scoped_variables(environment: nil)
end
end
def simple_variables_without_dependencies
strong_memoize(:variables_without_dependencies) do
scoped_variables(environment: nil, dependencies: false)
end
end
end
end
|