BigW Consortium Gitlab

builds.rb 795 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
      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
15

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

    private
22 23

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