Class: Ci::Ref
Constant Summary
collapse
- FAILING_STATUSES =
%w[failed broken still_failing].freeze
Gitlab::OptimisticLocking::MAX_RETRIES
ApplicationRecord::MAX_PLUCK
HasCheckConstraints::NOT_NULL_CHECK_PATTERN
ResetOnColumnErrors::MAX_RESET_PERIOD
Class Method Summary
collapse
Instance Method Summary
collapse
log_optimistic_lock_retries, retry_lock, retry_lock_histogram, retry_lock_logger
#run_after_commit, #run_after_commit_or_now
model_name, table_name_prefix
===, cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, nullable_column?, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
#reset_on_union_error, #reset_on_unknown_attribute_error
#serializable_hash
Class Method Details
.ensure_for(pipeline) ⇒ Object
36
37
38
|
# File 'app/models/ci/ref.rb', line 36
def ensure_for(pipeline)
safe_find_or_create_by(project_id: pipeline.project_id, ref_path: pipeline.source_ref_path)
end
|
.failing_state?(status_name) ⇒ Boolean
40
41
42
|
# File 'app/models/ci/ref.rb', line 40
def failing_state?(status_name)
FAILING_STATUSES.include?(status_name)
end
|
Instance Method Details
#artifacts_locked? ⇒ Boolean
53
54
55
|
# File 'app/models/ci/ref.rb', line 53
def artifacts_locked?
self.pipelines.where(locked: :artifacts_locked).exists?
end
|
#last_finished_pipeline ⇒ Object
#last_finished_pipeline_id ⇒ Object
45
46
47
|
# File 'app/models/ci/ref.rb', line 45
def last_finished_pipeline_id
last_finished_pipeline&.id
end
|
#last_successful_ci_source_pipeline ⇒ Object
70
71
72
|
# File 'app/models/ci/ref.rb', line 70
def last_successful_ci_source_pipeline
pipelines.ci_sources.success.order(id: :desc).first
end
|
#last_unlockable_ci_source_pipeline ⇒ Object
74
75
76
|
# File 'app/models/ci/ref.rb', line 74
def last_unlockable_ci_source_pipeline
pipelines.ci_sources.with_unlockable_status.order(id: :desc).first
end
|
#update_status_by!(pipeline) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'app/models/ci/ref.rb', line 57
def update_status_by!(pipeline)
retry_lock(self, name: 'ci_ref_update_status_by') do
next unless last_finished_pipeline_id == pipeline.id
case pipeline.status
when 'success' then self.succeed
when 'failed' then self.do_fail
end
self.status_name
end
end
|