BigW Consortium Gitlab

builds.rb 796 Bytes
Newer Older
1 2 3 4 5
module Emails
  module Builds
    def build_fail_email(build_id, to)
      @build = Ci::Build.find(build_id)
      @project = @build.project
6

7
      add_project_headers
8
      add_build_headers('failed')
9

10 11 12 13 14 15
      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
16

17
      add_project_headers
18
      add_build_headers('success')
19 20
      mail(to: to, subject: subject("Build success for #{@project.name}", @build.short_sha))
    end
21 22

    private
23 24

    def add_build_headers(status)
25 26
      headers['X-GitLab-Build-Id'] = @build.id
      headers['X-GitLab-Build-Ref'] = @build.ref
27
      headers['X-GitLab-Build-Status'] = status.to_s
28
    end
29 30
  end
end