debian-mirror-gitlab/lib/gitlab/ci/pipeline/chain/create.rb
2018-03-17 18:26:18 +05:30

45 lines
1.1 KiB
Ruby

module Gitlab
module Ci
module Pipeline
module Chain
class Create < Chain::Base
include Chain::Helpers
def perform!
::Ci::Pipeline.transaction do
pipeline.save!
@command.seeds_block&.call(pipeline)
::Ci::CreatePipelineStagesService
.new(project, current_user)
.execute(pipeline)
end
rescue ActiveRecord::RecordInvalid => e
error("Failed to persist the pipeline: #{e}")
ensure
if pipeline.builds.where(stage_id: nil).any?
invalid_builds_counter.increment(node: hostname)
end
end
def break?
!pipeline.persisted?
end
private
def invalid_builds_counter
@counter ||= Gitlab::Metrics
.counter(:gitlab_ci_invalid_builds_total,
'Invalid builds without stage assigned counter')
end
def hostname
@hostname ||= Socket.gethostname
end
end
end
end
end
end