perlPractioner has asked for the wisdom of the Perl Monks concerning the following question:

Honorable Monks, I am trying to access JIRA, which is basically an issue tracking system where clients can create a ticket for daily problems that arise and then close the ticket when the issue is resolved. I am using Perl's JIRA::Client module to retrieve all the issues from a JIRA filter already created. To accomplish this, I am using set_filter_iterator and then looping through until there are no more issues left in the filter (basically when issues = undefined). The code looks like this:

#!/usr/bin/perl -w use LWP::UserAgent; use JIRA::Client; use SOAP::Lite; my $user = 'username' my $pw = 'password' my $filterID = '12345'; my $jira=JIRA::Client->new('http://example.com/jira',$user,$pw); $jira->set_filter_iterator('$filterID'); while (my $issue = $jira->next_issue()) { print "$issue\n"; }

What is being returned is "RemoteIssue=HASH(******)" for each issue. For example, if there are currently 20 issues in the filter, the script returns 20 "RemoteIssues=HASH(******)", each having a different hash value. Instead of getting the RemoteIssue object with the issues' hash values, I'd like to get the actual data for each issue (e.g. date, status, reporter, etc.). Any ideas would greatly be appreciated. Thanks in advance monks!

Replies are listed 'Best First'.
Re: JIRA::Client returning "RemoteIssue=HASH(******)"
by keszler (Priest) on Dec 03, 2011 at 15:46 UTC

    Try it this way:

    #!/usr/bin/perl use strict; use warnings; use Data::Dumper; use LWP::UserAgent; use JIRA::Client; use SOAP::Lite; my $user = 'username'; my $pw = 'password'; my $filterID = '12345'; my $jira=JIRA::Client->new('http://example.com/jira',$user,$pw); $jira->set_filter_iterator('$filterID'); while (my $issue = $jira->next_issue()) { print Dumper($issue); }
    If that doesn't clarify things for you, reply back here with the result.

      Worked like a charm! Much appreciated! I received back the following:

      $VAR1=bless( { 'priority' => '2', 'customFieldValues' => [ bless( { 'customfieldID' => 'cus +tomfield_12345', 'values' => ['John Smit +h'], 'key' => undef}, 'RemoteCustomFieldValue +' ), bless ...

      It seems as if I will have to identify the customfieldIDs that I'm interested in and get the corresponding values. Do you know of another way to accomplish this other than parsing the output for the customfieldID then obtaining the hash tag value for "values"? Thanks again.

        Each $issue returned by $jira->next_issue is a blessed object with its own methods for getting and setting information. The JIRA::Client documentation doesn't have a lot of detail, and the source isn't much better. Try:

        while (my $issue = $jira->next_issue()) { #print Dumper($issue); my $custom_fields_ref = $issue->get_custom_fields(); for my $cf_name (keys %{$custom_fields_ref}) { print ">>$cf_name<< = >>>$custom_fields_ref->{$cf_name}<<<\n"; } print 'Priority: ', $issue->priority, $/; # do as above for other fields at the same level as 'priority' => 2 }