Welcome to mirror list, hosted at ThFree Co, Russian Federation.

build_success_worker.rb « workers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f35303170903bc3d2e2376edb52fcbb650f44d38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

class BuildSuccessWorker
  include ApplicationWorker
  include PipelineQueue

  queue_namespace :pipeline_processing

  # rubocop: disable CodeReuse/ActiveRecord
  def perform(build_id)
    Ci::Build.find_by(id: build_id).try do |build|
      create_deployment(build) if build.has_environment?
    end
  end
  # rubocop: enable CodeReuse/ActiveRecord

  private

  ##
  # Deprecated:
  # As of 11.5, we started creating a deployment record when ci_builds record is created.
  # Therefore we no longer need to create a deployment, after a build succeeded.
  # We're leaving this code for the transition period, but we can remove this code in 11.6.
  def create_deployment(build)
    build.create_deployment.try do |deployment|
      deployment.succeed
    end
  end
end