2018-12-13 13:39:08 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
module Pipeline
|
|
|
|
module Chain
|
|
|
|
class Create < Chain::Base
|
|
|
|
include Chain::Helpers
|
2022-01-26 12:08:38 +05:30
|
|
|
include Gitlab::Utils::StrongMemoize
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
def perform!
|
2023-03-04 22:38:38 +05:30
|
|
|
logger.instrument_once_with_sql(:pipeline_save) do
|
2022-01-26 12:08:38 +05:30
|
|
|
BulkInsertableAssociations.with_bulk_insert do
|
2022-08-13 15:12:31 +05:30
|
|
|
::Ci::BulkInsertableTags.with_bulk_insert_tags do
|
2022-03-02 08:16:31 +05:30
|
|
|
pipeline.transaction do
|
|
|
|
pipeline.save!
|
2022-08-13 15:12:31 +05:30
|
|
|
Gitlab::Ci::Tags::BulkInsert.bulk_insert_tags!(statuses)
|
2022-03-02 08:16:31 +05:30
|
|
|
end
|
2022-01-26 12:08:38 +05:30
|
|
|
end
|
|
|
|
end
|
2020-07-28 23:09:34 +05:30
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
rescue ActiveRecord::RecordInvalid => e
|
|
|
|
error("Failed to persist the pipeline: #{e}")
|
|
|
|
end
|
|
|
|
|
|
|
|
def break?
|
|
|
|
!pipeline.persisted?
|
|
|
|
end
|
2022-01-26 12:08:38 +05:30
|
|
|
|
|
|
|
private
|
|
|
|
|
2022-03-02 08:16:31 +05:30
|
|
|
def statuses
|
|
|
|
strong_memoize(:statuses) do
|
|
|
|
pipeline
|
|
|
|
.stages
|
|
|
|
.flat_map(&:statuses)
|
|
|
|
.select { |status| status.respond_to?(:tag_list) }
|
2022-01-26 12:08:38 +05:30
|
|
|
end
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|