debian-mirror-gitlab/lib/gitlab/ci/build/context/base.rb

64 lines
1.4 KiB
Ruby
Raw Normal View History

2019-12-26 22:10:19 +05:30
# frozen_string_literal: true
module Gitlab
module Ci
module Build
module Context
class Base
2021-12-11 22:18:48 +05:30
include Gitlab::Utils::StrongMemoize
2019-12-26 22:10:19 +05:30
attr_reader :pipeline
def initialize(pipeline)
@pipeline = pipeline
end
def variables
raise NotImplementedError
end
2022-01-26 12:08:38 +05:30
def variables_hash
strong_memoize(:variables_hash) do
variables.to_hash
end
end
2021-12-11 22:18:48 +05:30
def project
pipeline.project
end
def sha
pipeline.sha
end
def top_level_worktree_paths
strong_memoize(:top_level_worktree_paths) do
project.repository.tree(sha).blobs.map(&:path)
end
end
def all_worktree_paths
strong_memoize(:all_worktree_paths) do
project.repository.ls_files(sha)
end
end
2019-12-26 22:10:19 +05:30
protected
def pipeline_attributes
{
pipeline: pipeline,
project: pipeline.project,
user: pipeline.user,
ref: pipeline.ref,
tag: pipeline.tag,
trigger_request: pipeline.legacy_trigger,
protected: pipeline.protected_ref?
}
end
end
end
end
end
end