Create SCRUM Cards from JIRA

Introduction

We at our office want to use a plain old physical SCRUM board. This board contains all the issues we currently work on during a sprint and we have the satisfaction of having something to touch during our daily  SCRUM meetings. Unfortunately we also use jira as issue tracker and I am somewhat to lazy to write a card for every jira issue. Therefore the preferred solution is printing out scrum cards directly from jira.

Now you will say: Well just use: http://www.spartez.com/en/products-plugins-jira-idea.html or http://www.atlassian.com/software/greenhopper/ . Unfortunately for me those tools cost some amount of cash. So I had to write a script myself which can create scrum cards from my jira issues.

Goal

I want SCRUM cards looking like this:

Oldschool Scrum Card

Those SCRUM cards should be generated from jira which looks like this (thank you hibernate guys for letting me borrow your issues):

Solution

In order to create the cards from the issues I first need the issues in a machine readable format. Luckily jira provides us an export to XML which is suffienct for all our needs.  If you don’t know where the export is: check out the jira screenshot above. The export leaves us with an XML file like this: JiraSearch

This XML File needs to be processed and some scrum cards should be created out of them. The easiest way of doing this for me was using an reporting tool called iReport. With this tool I “just” created a report which looks like me scrum cards. Basis for this report is the XML file, which it also can use as datasource. The report creation in iReport looks somewhat like this:

Now when testing the report I get my perfect SCRUM cards (like I want them) in a pdf which looks like this. The saved report is downloadable here.

Of course always loading up this report designer, just because I want to create some SCRUM cards is not really convenient. So as the trusty Java Programmer which I am, i whipped up an java application which heavily relies on the jasperReports library. The jasperReports is what iReport uses in the background to create those reports. So I can use the (compiled) output of iReport and use it in my java program. The java program reads files from an input folder and creates pdfs in an output folder. The whole sourcecode (minus the filename filter) fits nicely in around 50 lines of code.

package org.insanedevelopment.scrum;

import java.io.File;
import java.io.InputStream;
import java.util.HashMap;

import net.sf.jasperreports.engine.JRExporter;
import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.data.JaxenXmlDataSource;
import net.sf.jasperreports.engine.export.JRPdfExporter;

public class JiraToScrumReport {

	private static final String JASPER_TEMPLATE = "ScrumSheets.jasper";

	public void createPDF(String filename) throws Exception {
		File inputFile = new File(filename);
		// Fill the report using an empty data source
		InputStream report = JiraToScrumReport.class.getResourceAsStream(JASPER_TEMPLATE);
		JasperPrint print = JasperFillManager.fillReport(report, new HashMap<String, String>(), new JaxenXmlDataSource(inputFile,
				"/rss/channel/item"));

		// Create a PDF exporter
		JRExporter exporter = new JRPdfExporter();

		// Configure the exporter (set output file name and print object)
		String outputFileName = "output/" + inputFile.getName().replace(".xml", "") + ".pdf";
		exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, outputFileName);
		exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);

		// Export the PDF file
		exporter.exportReport();
	}

	public void createPDFsFromFolder(String folder) throws Exception {
		File directory = new File(folder);
		String[] fileNames = directory.list(new XmlFileNameFilter());
		for (String filename : fileNames) {
			createPDF(directory.getAbsolutePath() + "/" + filename);
		}
	}

	public static void main(String[] args) throws Exception {
		new JiraToScrumReport().createPDFsFromFolder("input");
	}
}

This is all that is needed to create the cards out of the xml files. You can download the source code of this project here. It runs out of eclipse and just needs the jasperReports libraries in the lib dir to run.

WordPress Appliance - Powered by TurnKey Linux