Class: Ci::Ref
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ApplicationRecord
- Ci::Ref
- Includes:
- AfterCommitQueue, Gitlab::OptimisticLocking
- Defined in:
- app/models/ci/ref.rb
Constant Summary collapse
- FAILING_STATUSES =
%w[failed broken still_failing].freeze
Constants included from Gitlab::OptimisticLocking
Gitlab::OptimisticLocking::MAX_RETRIES
Constants inherited from ApplicationRecord
Constants included from ResetOnUnionError
ResetOnUnionError::MAX_RESET_PERIOD
Class Method Summary collapse
Instance Method Summary collapse
- #artifacts_locked? ⇒ Boolean
- #last_finished_pipeline_id ⇒ Object
- #update_status_by!(pipeline) ⇒ Object
Methods included from Gitlab::OptimisticLocking
log_optimistic_lock_retries, retry_lock, retry_lock_histogram, retry_lock_logger
Methods included from AfterCommitQueue
#run_after_commit, #run_after_commit_or_now
Methods inherited from ApplicationRecord
Methods inherited from ApplicationRecord
cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, 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
Methods included from SensitiveSerializableHash
Class Method Details
.ensure_for(pipeline) ⇒ Object
45 46 47 |
# File 'app/models/ci/ref.rb', line 45 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
49 50 51 |
# File 'app/models/ci/ref.rb', line 49 def failing_state?(status_name) FAILING_STATUSES.include?(status_name) end |
Instance Method Details
#artifacts_locked? ⇒ Boolean
58 59 60 |
# File 'app/models/ci/ref.rb', line 58 def artifacts_locked? self.pipelines.where(locked: :artifacts_locked).exists? end |
#last_finished_pipeline_id ⇒ Object
54 55 56 |
# File 'app/models/ci/ref.rb', line 54 def last_finished_pipeline_id Ci::Pipeline.last_finished_for_ref_id(self.id)&.id end |
#update_status_by!(pipeline) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/models/ci/ref.rb', line 62 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 |