parse input fiile to array before provcessing

This commit is contained in:
Trevor Batley 2023-06-06 11:45:25 +10:00
parent f2b2c021f8
commit 0c2b8da54f

View File

@ -86,9 +86,10 @@ for param in $3 $4 $5 $6; do
fi fi
done done
# Build array of parameters to cycle through
PARAMLIST=
if [ $PROCESSORG ] ; then if [ $PROCESSORG ] ; then
# cycle through the repos in the specified organisation # get a list of repositories in the source organisation and store in array of parameters
# get a list of repositories in the source organisation
for page in {1..10} ; do for page in {1..10} ; do
if [ $DEBUG ] ; then echo "getting page $page of repos from $GITEAHOST $PROCESSORG" ; fi if [ $DEBUG ] ; then echo "getting page $page of repos from $GITEAHOST $PROCESSORG" ; fi
RESPONSE=$(curl -s -X 'GET' \ RESPONSE=$(curl -s -X 'GET' \
@ -105,19 +106,23 @@ if [ $PROCESSORG ] ; then
echo $RESPONSE | grep -oP '(?<="name":").+?(?=")' | while read repo; do echo $RESPONSE | grep -oP '(?<="name":").+?(?=")' | while read repo; do
if [[ $NOISY || $REVIEW ]] ; then echo "$2 $repo $EXTRAPARAMS" ; fi if [[ $NOISY || $REVIEW ]] ; then echo "$2 $repo $EXTRAPARAMS" ; fi
if [[ ! $REVIEW ]] ; then if [[ ! $REVIEW ]] ; then
if [[ $repo ]] ; then $2 $repo $EXTRAPARAMS ; fi if [[ $repo ]] ; then $PARAMLIST+=$repo ; fi
fi fi
done done
fi fi
done done
else else
# read through input file and run script using params from file # load array of parameters from input file
while read -r line while read -r line ; do $PARAMLIST+=$line ; done < $1
fi
# Cycle through array of parameters and execute script
for param in "${PARAMLIST[@]}"
do do
if [[ $NOISY || $REVIEW ]] ; then echo "$2 $line $EXTRAPARAMS" ; fi if [[ $NOISY || $REVIEW ]] ; then echo "$2 $param $EXTRAPARAMS" ; fi
if [[ ! $REVIEW ]] ; then if [[ ! $REVIEW ]] ; then
if [[ $line ]] ; then $2 $line $EXTRAPARAMS ; fi if [[ $line ]] ; then $2 $param $EXTRAPARAMS ; fi
fi
done < $1
fi fi
done
exit 0 exit 0