I have script to do a few jobs:
- list config
XMLs. - list which of those
XMLs have a match. - show what that match is.
JENKINS_HOME=/var/lib/jenkins
_ALL_JOBS=$( find $JENKINS_HOME/jobs -name config.xml )
_CRON_JOBS=$( for _JOB in $( echo "$_ALL_JOBS" ); do grep -l 'triggers.TimerTrigger' $_JOB; done )
for _JOB in $( echo "$_CRON_JOBS" ); do
_TIME_TRIGGER=$( grep -A 1 'hudson.triggers.TimerTrigger' $_JOB | head -2 | tail -1 )
echo ${_JOB}: $_TIME_TRIGGER
done
$_ALL_JOBS something like:
/var/lib/jenkins/jobs/Testing/jobs/job1/config.xml
/var/lib/jenkins/jobs/Testing/jobs/job2/config.xml
/var/lib/jenkins/jobs/Testing/jobs/job3/config.xml
/var/lib/jenkins/jobs/Testing/jobs/job4/config.xml
/var/lib/jenkins/jobs/Testing/jobs/job5/config.xml
$_CRON_JOBS is a selection $_ALL_JOBS and looks something like:
/var/lib/jenkins/jobs/Testing/jobs/job2/config.xml
/var/lib/jenkins/jobs/Testing/jobs/job4/config.xml
/var/lib/jenkins/jobs/Testing/jobs/job5/config.xml
When I run GREP from the command line on one of these files, I get something like this back: <spec>H 1 * * *</spec>
When I run the same command on every file in a loop, I get this back plus the contents of the directory I'm currently working in:
<spec>H */6 file1 file2 file3 file4 file5*</spec>
If I change to a different working directory and run the script, I get the same thing, but the files that appear in between the XML tags are the those of the new working directory:
<spec>H */6 file6 file7 file8 file9 file10*</spec>
Is there something about the loop or the contents of the match that's causing the contents of my current working directory to be sandwiched inside the match?
Thanks for any thoughts.