2016-10-13 06:58:25 -04:00
|
|
|
class BuildSuccessWorker
|
|
|
|
include Sidekiq::Worker
|
2016-10-21 12:13:41 -04:00
|
|
|
include BuildQueue
|
2016-10-13 06:58:25 -04:00
|
|
|
|
|
|
|
def perform(build_id)
|
|
|
|
Ci::Build.find_by(id: build_id).try do |build|
|
2016-10-13 09:24:33 -04:00
|
|
|
create_deployment(build)
|
2016-10-13 06:58:25 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2016-10-13 09:24:33 -04:00
|
|
|
def create_deployment(build)
|
2016-10-13 06:58:25 -04:00
|
|
|
return if build.environment.blank?
|
|
|
|
|
|
|
|
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
|