Hudson and Jira

Hudson comes with a decent JIRA plugin but its not very customizable. When we run our CI build we deploy into our QA environment. As a second step we want to move the JIRA items deployed into the ‘In QA’ status. You can do this manually but it is nice to automate it !

Jira CLI

Jira CLI is an excellent tool. Very easy to setup and use. Here is a sample script which connects to Jira, finds the issues which have been resolved and updates their status.

declare -a TOKENS
declare -i STATUS_RESOLVED=5
declare -i STATUS

# Declare JIRA details
JIRA_VERSION="Iteration 3"
JIRA_CMD_LINE="/home/hudson/jira/ --user abc --password abc"

echo "Getting all issues from Jira.."
echo "$JIRA_CMD_LINE -a getIssueList --filter "$JIRA_VERSION" --file tmp.txt"
echo `$JIRA_CMD_LINE -a getIssueList --filter "$JIRA_VERSION" --file tmp.txt`
echo -e "Done. \n"

if [ -e tmp.txt ]
 # Loop through Jira issues (file)
 echo "Resolved Jiras in $JIRA_VERSION"

 while read line
 TOKENS=(`echo $line | tr "," " "`)

 echo `$JIRA_CMD_LINE -a progressIssue --issue "$JIRA_NUMBER" --step "In QA Issue" --resolution "Fixed"`
 done < tmp.txt

 #Clean up
 rm tmp.txt

Integrating with Hudson

You will need to install Jira CLI on the Hudson box. This is pretty straightforward.

The easiest way is to run this script at the end of the Hudson run – via bash. If your Hudson build fails, the script will not be run and the Jira will remain unchanged. Works out nicely.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s