Backend: Decouple scoped variables from the job record
When creating a new pipeline we use rules to evaluate if a job should be part of the pipeline, but for doing this we need to have access to its variables and currently the only way of doing it is through the ActiveRecord object:
def variables
strong_memoize(:variables) do
# 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.
stub_build.scoped_variables
end
end
private
def stub_build
::Ci::Build.new(build_attributes)
end
Initializing an ActiveRecord for every job from the pipeline is expensive, considering that there are pipelines that start with thousands of jobs and create only a few jobs in the end:
from !72602 (comment 717451090)
Removing this dependency of would yield a significant performance boost for the Chain::Seed
step in the pipeline creation.
Proposal
Remove the need to have an actual AR object to access scoped_variables
Edited by Mark Nuzzo