add org= option
This commit is contained in:
parent
a7eebc7ac7
commit
7fb53cc776
@ -8,6 +8,8 @@ if [[ -z $1 ]] ; then
|
|||||||
echo "<param file> = name of file containing parameters"
|
echo "<param file> = name of file containing parameters"
|
||||||
echo "<script> script to run (e.g. rename-e-smith-pkh.sh)"
|
echo "<script> script to run (e.g. rename-e-smith-pkh.sh)"
|
||||||
echo "optional params can appear in any order"
|
echo "optional params can appear in any order"
|
||||||
|
echo " <org='organisation'> run for each repo in 'organisation' (e.g. org=smeserver)"
|
||||||
|
echo " <review> show line being executed but do NOTHING!"
|
||||||
echo " <noisy> show line being executed"
|
echo " <noisy> show line being executed"
|
||||||
echo " <additional> additional params to be passed (up to 3)"
|
echo " <additional> additional params to be passed (up to 3)"
|
||||||
exit 0
|
exit 0
|
||||||
@ -23,13 +25,20 @@ if [[ $(which $2 | grep "no $2") ]] ; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
REVIEW=
|
||||||
NOISY=
|
NOISY=
|
||||||
|
PROCESSORG=
|
||||||
EXTRAPARAMS=
|
EXTRAPARAMS=
|
||||||
for param in $3 $4 $5 $6; do
|
for param in $3 $4 $5 $6; do
|
||||||
if [ $param ] ; then
|
if [ $param ] ; then
|
||||||
case $param in
|
case $param in
|
||||||
|
review )
|
||||||
|
REVIEW=true ;;
|
||||||
noisy )
|
noisy )
|
||||||
NOISY=true ;;
|
NOISY=true ;;
|
||||||
|
org=* )
|
||||||
|
PROCESSORG=${$param#*=}
|
||||||
|
;;
|
||||||
* )
|
* )
|
||||||
EXTRAPARAMS=$EXTRAPARAMS" "$param ;;
|
EXTRAPARAMS=$EXTRAPARAMS" "$param ;;
|
||||||
esac
|
esac
|
||||||
@ -38,10 +47,38 @@ for param in $3 $4 $5 $6; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ $PROCESSORG ] ; then
|
||||||
|
# cycle through the repos in the specified organisation
|
||||||
|
# get a list of repositories in the source organisation
|
||||||
|
for page in {1..10} ; do
|
||||||
|
if [ $DEBUG ] ; then echo "getting page $page of repos from $GITHOST $1" ; fi
|
||||||
|
RESPONSE=$(curl $curlsilent -X 'GET' \
|
||||||
|
"$GITEAHOST/api/v1/orgs/$1/repos?page=$page" \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H "Authorization: token $ACCESSTOKEN"
|
||||||
|
)
|
||||||
|
if [ $DEBUG ] ; then echo "RESPONSE=$RESPONSE" ; fi
|
||||||
|
|
||||||
|
if [[ $RESPONSE == '[]' ]] ; then
|
||||||
|
# we have them all
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo $RESPONSE | grep -oP '(?<="name":").+?(?=")' | while read repo; do
|
||||||
|
if [[ $NOISY || $REVIEW ]] ; then echo "$2 $repo $EXTRAPARAMS" ; fi
|
||||||
|
if [[ ! $REVIEW ]] ; then
|
||||||
|
if [[ $repo ]] ; then $2 $repo $EXTRAPARAMS ; fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
# read through input file and run script using params from file
|
# read through input file and run script using params from file
|
||||||
while read -r line
|
while read -r line
|
||||||
do
|
do
|
||||||
if [[ $NOISY ]] ; then echo "$2 $line $EXTRAPARAMS" ; fi
|
if [[ $NOISY || $REVIEW ]] ; then echo "$2 $line $EXTRAPARAMS" ; fi
|
||||||
|
if [[ ! $REVIEW ]] ; then
|
||||||
if [[ $line ]] ; then $2 $line $EXTRAPARAMS ; fi
|
if [[ $line ]] ; then $2 $line $EXTRAPARAMS ; fi
|
||||||
|
fi
|
||||||
done < $1
|
done < $1
|
||||||
|
fi
|
||||||
exit 0
|
exit 0
|
Loading…
Reference in New Issue
Block a user