gj2666 has asked for the wisdom of the Perl Monks concerning the following question:
The evil Java build automation developers I work with want to move the Hudson jobs to a different location, however the paths are too long and windows just whines when I try to move them. (see output at bottom)
I could alter them manually by changing several paths manually, but whenever the job runs again it updates whatever was there with the current path too foul. Can't get them all renamed manually before new ones are created.
So I tried something I found here the other day, but it fails to execute the move command here: (And yes, I have wicked skills, but not in a good way.)
$olddirname is the full path to the dir I want to rename (shorten). $newname is the new name of the dir (no path) executed (via the ..) to position me in the parent dir of the one I want to change. My question is...what is another approach that I could make work since making a system call and using the dos commands seems to be a bust.H:; cd $olddirname; cd ..; move /Y $olddirname $newname` or die "Can't + move $olddirname $newname: $!";
Output:#!perl # # fixlength.pl # Script to browse a file path (for hudson jobs)and find "target" # directories and shorten the pathname by renaming several common # directory names dir /s /b Zz* # $File::Find::dir = /some/path/ # $_ = foo.ext # $File::Find::name = /some/path/foo.ext # use strict; use warnings; use File::Find; #used to traverse a directory tree my $count; my $char; my @pathname; # open (FILE, "<$file") or die "Can't open $file: $!"; my $directory = "H:/softwaredistribution/hudson/jobs/"; finddepth(\&process_file, $directory); #---------------------------------------------------------------- # Sub Routines start here #---------------------------------------------------------------- sub process_file{ foreach (my $dir = $File::Find::dir){ my $dir1=$File::Find::name; if (($_ ne "\.")&&($_ ne "\..")){ print "Dir is : $File::Find::dir \n file is :$_ \n and fu +llpathname is : $File::Find::name \n"; my %rephash=("target"=>"t", "checkout"=>"co", "was6-maven- +plugin"=>"w6","SNAPSHOT"=>"S"); my @keys = %rephash; my @value = %rephash; foreach my $key (sort keys %rephash){ if ($dir1=~m/$key$/) { my $olddirname=$dir1; $_=$dir1; # s/$key/$rephash{$key}/g; my $newname=$rephash{$key}; print "Command is H:; cd $olddirname; cd ..; move +/Y $olddirname $newname \n"; `H:; cd $olddirname; cd ..; move /Y $olddirname $n +ewname` or die "Can't move $olddirname $newname: $!"; } } } } }
H:/softwaredistribution/hudson/jobs/Conservation_Payment_Release/workspace/trunk/target/checkout/conservation-ejb-batch/target/was6-maven-plugin; cd ..; move /Y H:/softwaredistribution/hudson/jobs/Conservation_Payment_Release/workspace/trunk/target/checkout/conservation-ejb-batch/target/was6-maven-plugin w6
Can't move H:/softwaredistribution/hudson/jobs/Conservation_Payment_Release/workspace/trunk/target/checkout/conservation-ejb-batch/target/was6-maven-plugin w6: at O:\RatlSupport_ML_dev\SRM-SoftwareDevCV\RatlSupport\Scripts\fixlength.pl line 42.
Line 42 is the `H:;...` In the output above we're trying to move (rename was6-maven-plugin to "w6").
All the output in trunk and below gets rewritten on build machine each new build and never commits to the SVN repository to it's okay to change on this server.
Thank you for your time and patience. gj
|
---|