#!/usr/bin/perl # HOW TO APPLY THE TRIGGER # # Triggers: # JIRA-FIX fix-add fix "/home/scm/perl-python-trigger.pl %user% %jobs%" # use strict; my ($passwd,$user,$job,$temp,$cmd,$val,$t)=""; my (@temp,@tarray)=(); # THIS IS THE PROTOTYPE VERSION # THE PERFORCE USER IDS AND PASSWORDS ARE STORED IN A CSV FILE IN /home/scm/proto-ldap.txt my $readfile="/home/scm/proto-ldap.txt"; my $logfile="/home/scm/perl-python-log.txt"; open(RFIL,"$readfile") or die "\n CANNOT OPEN $readfile FOR READ ACCESS:$!\n"; @temp=(<RFIL>); close(RFIL); if($#ARGV < 1) { exit 0; } $user=$ARGV[0]; $job=$ARGV[1]; $t=grep /$user/,@temp; if($t==1) { foreach(@temp) { $passwd=$_ if(/$user/); $passwd=~s/$user,?//; chomp($passwd); } } open(FIL,">>$logfile") or die "\n CANNOT OPEN FILE $logfile FOR WRITE ACCESS : $!\n"; print FIL "\nUser: $user\t Job: $job\n Password: $passwd\n"; $cmd="p4 job -o $job"; $val=`$cmd 2>&1`; if($?!=0) { print FIL "\nERROR: $val\n"; exit(1); } @tarray=split(/\n/,$val); #IF ANY JOBS ARE CLOSED, INVOKE THE PYTHON TRIGGER SCRIPT TO TRANSITION THE RESPECTIVE JIRA TICKETS TO "RESOLVED" STATE foreach(@tarray) { chomp($_); if(/^Status:\s+closed/) { print FIL "\nCommand: python /home/scm/closeIssue.py $user $passwd $job\n"; `python /home/scm/closeIssue.py $user $passwd $job`; close(FIL); exit 0; } } close(FIL);
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 7825 | Jai Siddagangappa |
Perforce-JIRA trigger scripts - Jaishankar Siddagangappa When you have Perforce and JIRA integrated and have imported the JIRA jobspec into Perforce, each JIRA ticket created will result in an associated Perforce job to be created. Unfortunately at this point, the reverse integration is not supported by Atlassian. When a Perforce Job is closed, the associated JIRA ticket must be transitioned from its current state (open, reopened, in progress) to the "Resolved" state. These triggers help achieve this. |