package MinJIRA; #============================================================================== # Copyright and license info is available in the LICENSE file included with # the Server Deployment Package (SDP), and also available online: # https://swarm.workshop.perforce.com/projects/perforce-software-sdp/view/main/LICENSE #------------------------------------------------------------------------------ =head1 NAME MinJIRA.pm - Minimal JIRA interface module. =head1 VERSION 1.1.1 =head1 DESCRIPTION Provides a minimal interface to JIRA via the JIRA REST API. =head1 PUBLIC DATA None =head1 PUBLIC FUNCTIONS =cut require Exporter; use strict; use JSON; use JIRA::Client::Automated; use Msg; # The next line avoids problems with 'use strict'. use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); # Initialization processing occurs in the BEGIN block. BEGIN { # Keep $VERSION value the same as at the top of this file. $VERSION = "1.1.1"; } # Package interface standards. By default, any export can be blocked. @ISA = qw(Exporter); # Prototypes for public functions. sub GetIssueStatus($$$$;); #============================================================================== # Internal Functions #============================================================================== #============================================================================== # Public Functions #============================================================================== #------------------------------------------------------------------------------ =head2 GetIssueStatus() GetIssueStatus ($I, $I, $I, $I;) =head3 Description-GetIssueStatus Determines if the MinJIRA is Mac. =head3 Parameters-GetIssueStatus =over 4 =item * $I - Self-explanatory. =item * $I URL for the JIRA server. =item * $I JIRA user for accessing the REST API. =item * $I Password for the JIRA user. =back =head3 Returns-GetIssueStatus Returns the JIRA issue status string on success. =cut #------------------------------------------------------------------------------ sub GetIssueStatus ($$$$;) { $Msg->trace("CALL MinJIRA::GetIssueStatus(@_)"); my ($issueKey, $jurl, $juser, $jpwd) = @_; my $jira; my %issueHash; my $issueHashRef; my %fieldsHash; my $fieldsHashRef; my %statusHash; my $statusHashRef; my $issueStatus = "Undefined_JIRA_Issue_Status"; if ($issueKey =~ /^\w+-\d+/) { $Msg->trace ("This issue key looks valid: [$issueKey]."); } else { $Msg->error ("This issue key does NOT look valid: [$issueKey]."); return $issueStatus; } $jira = JIRA::Client::Automated->new($jurl, $juser, $jpwd); $issueHashRef = $jira->get_issue ($issueKey); %issueHash = %$issueHashRef; $Msg->debug ("JIRA Issue top-level fileds:"); foreach (keys %issueHash) { $Msg->trace ("I: [$_]: [$issueHash{$_}]."); } $fieldsHashRef = $issueHash{'fields'}; %fieldsHash = %$fieldsHashRef; foreach (keys %fieldsHash) { $Msg->trace ("F: [$_]"); } $statusHashRef = $fieldsHash{'status'}; %statusHash = %$statusHashRef; foreach (keys %statusHash) { $Msg->trace ("S: [$_]"); } $issueStatus = $statusHash{'name'}; return $issueStatus; } # Return package load success. 1;