Class: CoberturaReportHelper

Inherits:
ExtensionHelper show all
Defined in:
lib/jenkins_pipeline_builder/extensions/helpers/publishers/cobertura_report_helper.rb

Instance Attribute Summary

Attributes inherited from ExtensionHelper

#builder, #params

Instance Method Summary collapse

Methods inherited from ExtensionHelper

#initialize

Constructor Details

This class inherits a constructor from ExtensionHelper

Instance Method Details

#send_metric_targets(target) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/jenkins_pipeline_builder/extensions/helpers/publishers/cobertura_report_helper.rb', line 25

def send_metric_targets(target)
  name = "#{target}Target"

  builder.instance_exec self do |helper|
    send name do
      targets 'class' => 'enum-map', 'enum-type' => 'hudson.plugins.cobertura.targets.CoverageMetric' do
        helper.thresholds[target].each do |threshold|
          entry do
            send('hudson.plugins.cobertura.targets.CoverageMetric') { text threshold[:type].upcase }
            send('int') { text(threshold[:value] * 100_000).to_i }
          end
        end
      end
    end
  end
end

#thresholdsObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/jenkins_pipeline_builder/extensions/helpers/publishers/cobertura_report_helper.rb', line 2

def thresholds
  @thresholds ||= params[:metric_targets]
  return @thresholds if @thresholds

  @thresholds = {
    failing: [
      { type: 'type', value: 0 },
      { type: 'line', value: 0 },
      { type: 'conditional', value: 0 }
    ],
    unhealthy: [
      { type: 'type', value: 0 },
      { type: 'line', value: 0 },
      { type: 'conditional', value: 0 }
    ],
    healthy: [
      { type: 'type', value: 80 },
      { type: 'line', value: 80 },
      { type: 'conditional', value: 70 }
    ]
  }
end