Class: Ci::PersistentRef

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
app/models/ci/persistent_ref.rb

Overview

The persistent pipeline ref to ensure runners can safely fetch source code even if force-push/source-branch-deletion happens.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pipelineObject

Returns the value of attribute pipeline


10
11
12
# File 'app/models/ci/persistent_ref.rb', line 10

def pipeline
  @pipeline
end

Instance Method Details

#createObject


22
23
24
25
26
27
# File 'app/models/ci/persistent_ref.rb', line 22

def create
  create_ref(sha, path)
rescue => e
  Gitlab::ErrorTracking
    .track_exception(e, pipeline_id: pipeline.id)
end

#deleteObject


29
30
31
32
33
34
35
36
# File 'app/models/ci/persistent_ref.rb', line 29

def delete
  delete_refs(path)
rescue Gitlab::Git::Repository::NoRepository
  # no-op
rescue => e
  Gitlab::ErrorTracking
    .track_exception(e, pipeline_id: pipeline.id)
end

#exist?Boolean

Returns:

  • (Boolean)

16
17
18
19
20
# File 'app/models/ci/persistent_ref.rb', line 16

def exist?
  ref_exists?(path)
rescue
  false
end

#pathObject


38
39
40
# File 'app/models/ci/persistent_ref.rb', line 38

def path
  "refs/#{Repository::REF_PIPELINES}/#{pipeline.id}"
end