Generating a task list from JIRA issues using XML-RPC and Groovy

by 12/02/2008 02:07:00 PM 0 comments

Generating a task list from JIRA issues using XML-RPC and Groovy

This is just a quick note demonstrating how to generate a task list from issues entered into JIRA. I use TaskPaper for creating GTD-style task lists for work and thought it might be handy to tack issues assigned to me in our JIRA issue tracker in the same way. To do so do the following:
  1. Install Groovy
  2. Download the Groovy XML-RPC module and copy it to $HOME/.groovy/lib
  3. Create a filter in JIRA to return tasks that you're interested in. Make note of the filterIdfor the filter you created.
  4. Create a shell script, here I'll call it jiratasks.groovy, and copy the following code into it:
    #!/usr/bin/env groovy
    import groovy.net.xmlrpc.XMLRPCServerProxy
    import java.text.SimpleDateFormat
    
    // Included to make pretty dates
    def dateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
    def dateFormat2 = new SimpleDateFormat("yyyy-MM-dd")
    
    // Connect to your server
    //Your URL may vary
    def server = new XMLRPCServerProxy("https://your.jira.server.net/rpc/xmlrpc") 
    def jira = server.jira1
    // Subsitute your username and password here
    def token = jira.login("your_username", "your_password")
    // Replace "10021" with your filterId  
    def issues = jira.getIssuesFromFilter(token, "10021")  
    
    // Sort by priority
    issues.sort { it.priority }
    
    // Get a list of projects
    def projects = issues.collect { it["project"]}
    projects.unique().sort()
    
    println "JIRA Issues:"
    projects.each { project ->
      println("\t${project}:")
      issues.each { issue ->
        if (issue["project"] == project) {
          def creationDate = dateFormat2.format(dateFormat1.parse(issue.created))
          println("\t- ${issue.key}: ${issue.summary} @created(${creationDate})")
        }
      }
    }
    
    jira.logout(token)
      
  5. Run it like: jiratasks.groovy > JIRATasks.taskpaper
  6. Voila. A GTD style tasks list that works with TaskPaper

Brian Schlining

Developer

Cras justo odio, dapibus ac facilisis in, egestas eget quam. Curabitur blandit tempus porttitor. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.

0 comments: