BigW Consortium Gitlab

build_success_worker.rb 563 Bytes
Newer Older
1 2
class BuildSuccessWorker
  include Sidekiq::Worker
3
  include BuildQueue
4 5 6

  def perform(build_id)
    Ci::Build.find_by(id: build_id).try do |build|
7
      create_deployment(build) if build.has_environment?
8 9 10 11 12
    end
  end

  private

13
  def create_deployment(build)
14 15 16 17 18 19 20 21 22 23 24 25
    service = CreateDeploymentService.new(
      build.project, build.user,
      environment: build.environment,
      sha: build.sha,
      ref: build.ref,
      tag: build.tag,
      options: build.options.to_h[:environment],
      variables: build.variables)

    service.execute(build)
  end
end