Module: Ci::Contextable
Overview
This module implements methods that provide context in form of essential CI/CD variables that can be used by a build / bridge job.
Instance Method Summary collapse
-
#scoped_variables(environment: expanded_environment_name, dependencies: true) ⇒ Object
Variables in the environment name scope.
-
#simple_variables ⇒ Object
Variables that do not depend on the environment name.
- #simple_variables_without_dependencies ⇒ Object
- #track_duration ⇒ Object
- #unprotected_scoped_variables(expose_project_variables:, expose_group_variables:, environment: expanded_environment_name, dependencies: true) ⇒ Object
Instance Method Details
#scoped_variables(environment: expanded_environment_name, dependencies: true) ⇒ Object
Variables in the environment name scope.
12 13 14 15 16 17 18 |
# File 'app/models/concerns/ci/contextable.rb', line 12 def scoped_variables(environment: , dependencies: true) track_duration do pipeline .variables_builder .scoped_variables(self, environment: environment, dependencies: dependencies) end end |
#simple_variables ⇒ Object
Variables that do not depend on the environment name.
54 55 56 57 58 |
# File 'app/models/concerns/ci/contextable.rb', line 54 def simple_variables strong_memoize(:simple_variables) do scoped_variables(environment: nil) end end |
#simple_variables_without_dependencies ⇒ Object
60 61 62 63 64 |
# File 'app/models/concerns/ci/contextable.rb', line 60 def simple_variables_without_dependencies strong_memoize(:variables_without_dependencies) do scoped_variables(environment: nil, dependencies: false) end end |
#track_duration ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/models/concerns/ci/contextable.rb', line 39 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 |
#unprotected_scoped_variables(expose_project_variables:, expose_group_variables:, environment: expanded_environment_name, dependencies: true) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/concerns/ci/contextable.rb', line 20 def unprotected_scoped_variables( expose_project_variables:, expose_group_variables:, environment: , dependencies: true) track_duration do pipeline .variables_builder .unprotected_scoped_variables( self, expose_project_variables: expose_project_variables, expose_group_variables: expose_group_variables, environment: environment, dependencies: dependencies ) end end |