Skip to content

Instantly share code, notes, and snippets.

@atoulme
Created April 23, 2011 01:17
Show Gist options
  • Save atoulme/938094 to your computer and use it in GitHub Desktop.
Save atoulme/938094 to your computer and use it in GitHub Desktop.
Extract Greenhopper graph from Jira using Ruby
require 'rubygems'
require 'net/http'
require 'hpricot'
SERVER = "jira.example.com"
GRAPH_URL = "/secure/ChartBoard.jspa?type=CCB&selectedProjectId=xxxxx&selectedBoardId=xxxxxx&colPage=1"
Net::HTTP.start(SERVER) {|http|
req = Net::HTTP::Get.new(GRAPH_URL)
resp = http.request(req)
html = Hpricot(resp.body)
graph = html.search("img").select {|src| src.to_s.match /\/charts/}[0].attributes["src"]
req2 = Net::HTTP::Get.new(graph)
File.open("file.png", "w+") { |f|
f.write http.request(req2).body
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment