Class: Pipeline::JiraReporter

Inherits:
BaseReporter show all
Defined in:
lib/pipeline/reporters/jira_reporter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseReporter

#out

Constructor Details

#initializeJiraReporter

Returns a new instance of JiraReporter.



12
13
14
15
# File 'lib/pipeline/reporters/jira_reporter.rb', line 12

def initialize()
  @name = "JiraReporter"  
  @format = :to_jira
end

Instance Attribute Details

#formatObject

Returns the value of attribute format.



10
11
12
# File 'lib/pipeline/reporters/jira_reporter.rb', line 10

def format
  @format
end

#nameObject

Returns the value of attribute name.



10
11
12
# File 'lib/pipeline/reporters/jira_reporter.rb', line 10

def name
  @name
end

Instance Method Details

#report(finding) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/pipeline/reporters/jira_reporter.rb', line 29

def report(finding)
	json = get_jira_json(finding)
	http = Curl.post("#{@api}/issue/", json.to_s) do |http|
		http.headers['Content-Type'] = "application/json"
		http.headers['Cookie'] = @cookie
	end
	if http.response_code != 201 # Created ...
		Pipeline.error "Problem with HTTP #{http.response_code} - #{http.body_str}"
	end
end

#run_report(tracker) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/pipeline/reporters/jira_reporter.rb', line 17

def run_report(tracker)
  @project = tracker.options[:jira_project.to_s]
  @api = tracker.options[:jira_api_url.to_s]
  @cookie = tracker.options[:jira_cookie.to_s]
  @component = tracker.options[:jira_component.to_s]

  tracker.findings.each do |finding|
  	report finding
  end
  "Results are in JIRA"
end