2015-12-07 07:23:23 -05:00
|
|
|
module Emails
|
|
|
|
module Builds
|
|
|
|
def build_fail_email(build_id, to)
|
|
|
|
@build = Ci::Build.find(build_id)
|
|
|
|
@project = @build.project
|
2016-02-11 09:08:10 -05:00
|
|
|
|
2015-12-19 14:04:40 -05:00
|
|
|
add_project_headers
|
2016-02-11 09:08:10 -05:00
|
|
|
add_build_headers('failed')
|
2016-07-12 17:19:47 -04:00
|
|
|
|
2015-12-07 07:23:23 -05:00
|
|
|
mail(to: to, subject: subject("Build failed for #{@project.name}", @build.short_sha))
|
|
|
|
end
|
|
|
|
|
|
|
|
def build_success_email(build_id, to)
|
|
|
|
@build = Ci::Build.find(build_id)
|
|
|
|
@project = @build.project
|
2016-02-11 09:08:10 -05:00
|
|
|
|
2015-12-19 14:04:40 -05:00
|
|
|
add_project_headers
|
2016-02-11 09:08:10 -05:00
|
|
|
add_build_headers('success')
|
2015-12-07 07:23:23 -05:00
|
|
|
mail(to: to, subject: subject("Build success for #{@project.name}", @build.short_sha))
|
|
|
|
end
|
2015-12-19 14:04:40 -05:00
|
|
|
|
|
|
|
private
|
2016-02-11 09:08:10 -05:00
|
|
|
|
|
|
|
def add_build_headers(status)
|
2015-12-19 14:04:40 -05:00
|
|
|
headers['X-GitLab-Build-Id'] = @build.id
|
|
|
|
headers['X-GitLab-Build-Ref'] = @build.ref
|
2016-02-11 09:08:10 -05:00
|
|
|
headers['X-GitLab-Build-Status'] = status.to_s
|
2015-12-19 14:04:40 -05:00
|
|
|
end
|
2015-12-07 07:23:23 -05:00
|
|
|
end
|
|
|
|
end
|