Archive

Archive for the ‘httparty’ Category

Automatically posting JIRA defects links to PresentlyApp.com

December 30th, 2008

On our team we thought it’d be useful to auto-post Blocker defects from Jira to our presently stream. The gems httparty and jira4r made it easy.

Here are the steps:

1. Install JIRA, create a user

2. Create a Filter for the defects you want to auto-post, get the ID for that filter from the URL when viewing it. ‘jiradmin’ in this example

3. Create a user on presently to post from. ‘jira’ in this example

4. Create a cron or windows tasks to run the following ruby code once per hour:

jira_presently.rb

#!/usr/bin/env ruby
require ‘rubygems’
require ‘httparty’
require ‘rexml/document’
require ‘jira4r/jira4r’

# make a HTTParty object for integrating with presentlyapp.com
class Presently
include HTTParty
# Presently api url
base_uri ‘https://[EXAMPLE].presentlyapp.com/api/twitter’
#jira presently user credentials
basic_auth ‘jira’, ‘[PRESENTLY PASSWORD]‘
default_params :output => ‘json’
format :json
end

# link to your JIRA server and credentials
JIRA_URL = “[http://jira.url.com/]”
jira = Jira::JiraTool.new(2, JIRA_URL)
jira.login(”jiraadmin”, “[JIRA PASSWORD]“)

#  Look at key in JIRA filter URL to get ID for the filter
issues = jira.getIssuesFromFilter(10112)

issues.each do |issue|
# post for the last 1 hour
if Time.parse(issue.created.to_s) > (Time.now – 60*60)
issue_post = “Blocker: ” + issue.key + ” – ” + issue.summary[0..75] + ” #{JIRA_URL}/browse/” + issue.key
puts Presently.post(’/statuses/update.json’, :query => {:status => issue_post}).inspect
else
puts issue.key + ” is older than 1 hour”
end
end

collaboration, httparty, jira4r, present.ly, presentlyapp, ruby, twitter, web2.0