Wednesday, August 12, 2015

Sample perl script to query JIRA

Using the Perl module http://search.cpan.org/~gnustavo/JIRA-REST-0.010/lib/JIRA/REST.pm

#!/usr/bin/perl -w
use strict;
use JIRA::REST;
use Data::Dumper;

my $jira = JIRA::REST->new('https://my.jira.net/jira', 'username', 'password');

# Get issue
my $issue = $jira->GET("/issue/TST-704");
#print Dumper($issue);

print "priority=$issue->{'fields'}->{'priority'}->{'name'}\n";
print "assignee=$issue->{'fields'}->{'assignee'}->{'name'}\n";
print "key=$issue->{'key'}\n";

# Iterate using utility methods
$jira->set_search_iterator({
        jql        => 'project = "TST" and issuetype in (Bug, scope) and fixVersion in (1.1r4, 1.1R4) and status in ( Closed, Resolved )',
        maxResults => -1,
        fields     => [ qw/summary status assignee/ ],
});

print "=================================================\n";
print "ISSUE-ID:STATUS:SUMMARY\n";
print "=================================================\n";
while (my $issue = $jira->next_issue) {
        #print "Found issue $issue->{key}\n";
        print "$issue->{key}: $issue->{fields}->{status}->{name}: $issue->{fields}->{summary}\n";
}

2 comments:

Anonymous said...

How to get the Created date time field for a particular JIRA issue.

The Skill Pedia said...

Thank you for sharing such an informative post. Keep posting.
Perl Scripting Training