Welcome to mirror list, hosted at ThFree Co, Russian Federation.

pipelines.rb « emails « mailers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e132105807ab959a0de9cc0102563f91d170c494 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
module Emails
  module Pipelines
    def pipeline_success_email(pipeline, to)
      pipeline_mail(pipeline, to, 'succeeded')
    end

    def pipeline_failed_email(pipeline, to)
      pipeline_mail(pipeline, to, 'failed')
    end

    private

    def pipeline_mail(pipeline, to, status)
      @project = pipeline.project
      @pipeline = pipeline
      add_headers

      mail(to: to, subject: pipeline_subject(status))
    end

    def add_headers
      add_project_headers
      add_pipeline_headers
    end

    def add_pipeline_headers
      headers['X-GitLab-Pipeline-Id'] = @pipeline.id
      headers['X-GitLab-Pipeline-Ref'] = @pipeline.ref
      headers['X-GitLab-Pipeline-Status'] = @pipeline.status
    end

    def pipeline_subject(status)
      subject(
        "Pipeline #{status} for #{@project.name}", @pipeline.short_sha)
    end
  end
end