2016-10-13 10:58:25 +00:00
|
|
|
class BuildSuccessWorker
|
|
|
|
include Sidekiq::Worker
|
2016-10-21 16:13:41 +00:00
|
|
|
include BuildQueue
|
2016-10-13 10:58:25 +00:00
|
|
|
|
|
|
|
def perform(build_id)
|
|
|
|
Ci::Build.find_by(id: build_id).try do |build|
|
2016-11-04 15:35:22 +00:00
|
|
|
create_deployment(build) if build.deployable?
|
2016-10-13 10:58:25 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2016-10-13 13:24:33 +00:00
|
|
|
def create_deployment(build)
|
2016-10-13 10:58:25 +00:00
|
|
|
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
|