Github To Jira Bug Migration Script

Recently I mentioned the github API and retrieving issues from it. This is because the 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('');
$data = json_decode(file_get_contents(''));

$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('' . $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);

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.

7 thoughts on “Github To Jira Bug Migration Script

  1. 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.

  2. 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 :)

  3. Pingback: Github Issues to JIRA - Kyle Cordes

Leave a Reply

Please use [code] and [/code] around any source code you wish to share.

This site uses Akismet to reduce spam. Learn how your comment data is processed.