Class: Gitlab::Ci::Build::Context::Base

Inherits:
Object
  • Object
show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/ci/build/context/base.rb

Direct Known Subclasses

Build, Global

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pipeline) ⇒ Base

Returns a new instance of Base.



12
13
14
# File 'lib/gitlab/ci/build/context/base.rb', line 12

def initialize(pipeline)
  @pipeline = pipeline
end

Instance Attribute Details

#pipelineObject (readonly)

Returns the value of attribute pipeline.



10
11
12
# File 'lib/gitlab/ci/build/context/base.rb', line 10

def pipeline
  @pipeline
end

Instance Method Details

#all_worktree_pathsObject



40
41
42
43
44
# File 'lib/gitlab/ci/build/context/base.rb', line 40

def all_worktree_paths
  strong_memoize(:all_worktree_paths) do
    project.repository.ls_files(sha)
  end
end

#projectObject



26
27
28
# File 'lib/gitlab/ci/build/context/base.rb', line 26

def project
  pipeline.project
end

#shaObject



30
31
32
# File 'lib/gitlab/ci/build/context/base.rb', line 30

def sha
  pipeline.sha
end

#top_level_worktree_pathsObject



34
35
36
37
38
# File 'lib/gitlab/ci/build/context/base.rb', line 34

def top_level_worktree_paths
  strong_memoize(:top_level_worktree_paths) do
    project.repository.tree(sha).blobs.map(&:path)
  end
end

#variablesObject

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/gitlab/ci/build/context/base.rb', line 16

def variables
  raise NotImplementedError
end

#variables_hashObject



20
21
22
23
24
# File 'lib/gitlab/ci/build/context/base.rb', line 20

def variables_hash
  strong_memoize(:variables_hash) do
    variables.to_hash
  end
end