[p4] Trigger script

Matthew Janulewicz mjanulew at alarismed.com
Wed Oct 6 09:33:19 PDT 2004


At the risk of getting slammed by people that actually know how to program  
in Perl, here is what we use. Unfortunately for you, it is in Perl. But we  
have used it on both Windows and Linux servers, and it seems to work fine.

We have a requirement that not only do we have to attach a job, but it has  
to be in a certain state (which it gets by syncing from our defect  
tracking tool.) It shouldn't be too hard to schmooze it to work in a more  
generic way.

My apologies to whoever I heisted this original code from. I found this  
base script in the Perforce public depot, but now I cen't find the  
original location to give credit.


-Matt


############################ code start:  jobs.pl
# Trigger to check that a submitted changelist has a job
# attached that is in a specific state. Pass in
# changenumber and serverport.

$ChangeNum = $ARGV[0];
$ServerPort = $ARGV[1];
$p4 = "p4 -p $ServerPort";

# Get info on our changelist
@ChangeInfo = `$p4 describe -s $ChangeNum`;

# Get list of jobs that are in the correct state
@ValidJobs = `$p4 jobs -e DevTrack_Status=3._Coding_and_Unit_Testing`;

# If there are valid jobs, check to see if one is attached
# to the current changelist
for $ValidJob (@ValidJobs) {
         ($ValidJob, undef) = split (/ /, $ValidJob);
         # Loop through each line in the current changelist description
         # looking for our current $ValidJob as we go
         foreach $ChangeInfo (@ChangeInfo) {
                 if ($ChangeInfo =~ $ValidJob) {
                         exit(0); # Let's accept this changelist
                 } # end if
         } # end foreach
} # end for

# If no valid jobs are found or are attached to our
changelist, fall through to this
print("\n\n***********************************************\n\n");
print("You must have at least one job in the\n");
print("\"Coding and Unit Testing\" state attached to\n");
print("this changelist to submit to this codeline!");
print("\n\n***********************************************\n\n");
exit(1); # Let's not accept this changelist
############################ code end



On Tue, 5 Oct 2004 22:19:14 -0700 (PDT), Xianzhou Guo <szguoxz at yahoo.com>  
wrote:

> I need a script to ensure a user must select a job
> with a changelist.
>
> The script I downloaded from perforce.com doesn't
> work. Who has a decent script which actually work on a
> Windows 2003? I really don't like perl though.
>
> Thanks,
> Calvin
>
>
> 		
> _______________________________
> Do you Yahoo!?
> Declare Yourself - Register online to vote today!
> http://vote.yahoo.com
> _______________________________________________
> perforce-user mailing list  -  perforce-user at perforce.com
> http://maillist.perforce.com/mailman/listinfo/perforce-user





More information about the perforce-user mailing list