2015-12-23 02:04:40 +05:30
|
|
|
module Emails
|
|
|
|
module Builds
|
|
|
|
def build_fail_email(build_id, to)
|
|
|
|
@build = Ci::Build.find(build_id)
|
|
|
|
@project = @build.project
|
2016-04-02 18:10:28 +05:30
|
|
|
|
2016-01-29 22:53:50 +05:30
|
|
|
add_project_headers
|
2016-04-02 18:10:28 +05:30
|
|
|
add_build_headers('failed')
|
2015-12-23 02:04:40 +05:30
|
|
|
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-04-02 18:10:28 +05:30
|
|
|
|
2016-01-29 22:53:50 +05:30
|
|
|
add_project_headers
|
2016-04-02 18:10:28 +05:30
|
|
|
add_build_headers('success')
|
2015-12-23 02:04:40 +05:30
|
|
|
mail(to: to, subject: subject("Build success for #{@project.name}", @build.short_sha))
|
|
|
|
end
|
2016-01-29 22:53:50 +05:30
|
|
|
|
|
|
|
private
|
2016-04-02 18:10:28 +05:30
|
|
|
|
|
|
|
def add_build_headers(status)
|
2016-01-29 22:53:50 +05:30
|
|
|
headers['X-GitLab-Build-Id'] = @build.id
|
|
|
|
headers['X-GitLab-Build-Ref'] = @build.ref
|
2016-04-02 18:10:28 +05:30
|
|
|
headers['X-GitLab-Build-Status'] = status.to_s
|
2016-01-29 22:53:50 +05:30
|
|
|
end
|
2015-12-23 02:04:40 +05:30
|
|
|
end
|
|
|
|
end
|