Skip to content

CI variables builder

Sean Arnold requested to merge sarnold-ci-variables-builder into master

What does this MR do and why?

This moves the CI Variables generation out of models and into a Gitlab::Ci::Variables::Builder class.

This class is the single entry-point for creating Ci Variables, and takes a pipeline argument to initialize it.

It uses dependency injection in order to generate variables for specific object - i.e for a Build you can call Gitlab::Ci::Variables::Builder.new(pipeline).job_variables(build).

This iterative step moves the variable generations for the following models:

  • Projects
  • Pipelines
  • Jobs (Build / Bridge)

Feature Flag

To ensure safety we put #scoped_variables behind a feature flag, gitlab_ci_pipeline_builder_scoped_variables_duration_tracking.

This is defaulted to enabled: true.

To measure performance of the #scoped_variable method, we add tracking to app/models/concerns/ci/contextable.rb which measures the duration (under gitlab_ci_pipeline_builder_scoped_variables_duration). As we move more methods into the Variable builder version of #scoped_variable, and add memoization, we should see the duration decline.

Related: #231300 (closed)

Screenshots or screen recordings

These are strongly recommended to assist reviewers and reduce the time to merge your change.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Sean Arnold

Merge request reports