Created
December 10, 2013 23:02
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
username: "fred" | |
password: "freds_password" | |
base_url: "https://jira.yourcompany.com" | |
jql_query: "assignee = \"fred\" AND project = NewProject AND status = Open" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 ofCGI.escape
, so just swapping inCGI.escape
fixes the problem.