Skip to content

Instantly share code, notes, and snippets.

@mattfinlayson
Created December 10, 2013 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattfinlayson/7902002 to your computer and use it in GitHub Desktop.
Save mattfinlayson/7902002 to your computer and use it in GitHub Desktop.
Little ruby script to take the results of a jql query (advanced search) in jira and create todo item's for Cultured Code's Things App. I use it at the beginning of a sprint to keep track of my own work and progress. If I get less lazy I could always sync back in the other direction.
username: "fred"
password: "freds_password"
base_url: "https://jira.yourcompany.com"
jql_query: "assignee = \"fred\" AND project = NewProject AND status = Open"
require 'httparty'
require 'open-uri'
require 'appscript'
require 'yaml'
config = YAML.load_file("config.yaml")
@username = config["username"]
@password = config["password"]
@base_url = config["base_url"]
@jql_query = config["jql_query"]
auth = {:username => @username, :password => @password}
query = URI::encode(@jql_query)
target = "#{@base_url}/rest/api/2/search?jql=#{query}"
response = HTTParty.get(target, :basic_auth => auth)
if response.code == 200
data = JSON.parse(response.body)
data['issues'].each do |issue|
puts "-------------------"
puts "#{issue['key']} - #{issue['fields']['summary']}"
puts issue['fields']['description']
puts
Appscript.app('Things').make(:new => :to_do, :with_properties => {:name => "#{issue['key']} - #{issue['fields']['summary']}", :notes=> "#{issue['fields']['description']}"})
end
end
@DanielDe
Copy link

Thanks for taking the time to post this, it just helped me out! :) But I did run into an interesting error that took me a while to track down, so I thought I'd note it here for others: The use of URI::encode here doesn't properly escape semicolons, which results in Mixpanel returning a parsing error if your JQL includes semicolons. URI::encode is deprecated in favor of CGI.escape, so just swapping in CGI.escape fixes the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment