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";
}

GIT - How to find commits made specific to a branch?

I want to find commits made specifically to the branch 'rel-7.4-r16'. Here is the command

Simple
git log  refs/remotes/origin/rel-7.4-r16 --not $(git for-each-ref --format='%(refname)' refs/remotes/origin|grep -v refs/remotes/origin/rel-7.4-r16)
with log pretty format
git  --date=iso --pretty=format:'%h %ad %an %s' 
 refs/remotes/origin/rel-7.4-r16 --not $(git for-each-ref --format='%(refname)' refs/remotes/origin|grep -v refs/remotes/origin/rel-7.4-r16)