Github To Jira Bug Migration Script
Recently I mentioned the github API and retrieving issues from it. This is because the joind.in project agreed to move its issue tracking from github to JIRA, since the issue tracker on github is far from feature complete. I migrated only our open issues, and comments (and the comments ended up a bit weirdly formatted on the other end but this was the best they could do). It was nothing pretty or clever but in case it’s useful to someone else, here’s the script:
$request = new HTTPRequest('http://github.com/api/v2/json/issues/list/joindin/joind.in/open');
$data = json_decode(file_get_contents('http://github.com/api/v2/json/issues/list/joindin/joind.in/open'));
$fp = fopen('joindin-issues.csv', 'w');
$titles = array('Summary', 'Reporter', 'DateCreated', 'Status', 'Description');
fputcsv($fp, $titles);
foreach($data->issues as $row) {
$output = array();
$comments = array();
$output[] = $row->title;
$output[] = $row->user;
$output[] = $row->created_at;
$output[] = 'Open';
$output[] = $row->body;
// handle comments
if($row->comments > 0) {
$comments = json_decode(file_get_contents('http://github.com/api/v2/json/issues/comments/joindin/joind.in/' . $row->number));
foreach($comments->comments as $comment_row) {
$created = strtotime($comment_row->created_at);
$output[] = 'Comment:'
. $comment_row->user . ':'
. date('m/d/y H:i:s A', $created) .':'
. $comment_row->body;
}
}
// write the line
fputcsv($fp, $output);
}
fclose($fp);
We moved to hosted JIRA studio and the only way to import to that is to email the CSV to the support team. I found that they were responsive within a few hours, and very polite and helpful.
Thanks for the input and sharing your findings..
Interesting, I had never heard about the HttpRequest class. You do not actually use it, though, so you might as well remove the first line. :-)
Thanks for sharing this snippet.
Jan: ha, good point! That object comes from pecl_http which I use a lot. I guess I thought the github API would be more complicated than it actually turned out to be, and I didn’t need anything more than the file_get_contents() calls you see there :)
Thanks for sharing this.
~Matt
As evidenced by the number of “Just for Fun” links, this wasn’t my most productive
Pingback: Github Issues to JIRA - Kyle Cordes
This plugin can import Github issues directly into Jira (without a CSV file)
https://marketplace.atlassian.com/plugins/com.atlassian.jira.plugins.jira-importers-github-plugin