8a9e73d8513f6961fa7a06e2487991bfad06a720
[releng.git] / jjb / ci_gate_security / anteater-clone-all-repos.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 set -o errexit
4 set -o pipefail
5 set -o nounset
6 export PATH=$PATH:/usr/local/bin/
7
8
9 #WORKSPACE="$(pwd)"
10
11 cd $WORKSPACE
12 if [ ! -d "$WORKSPACE/allrepos" ]; then
13   mkdir $WORKSPACE/allrepos
14 fi
15
16 cd $WORKSPACE/allrepos
17
18 declare -a PROJECT_LIST
19 EXCLUDE_PROJECTS="All-Projects|All-Users|securedlab"
20
21 PROJECT_LIST=($(ssh gerrit.opnfv.org -p 29418 gerrit ls-projects | egrep -v $EXCLUDE_PROJECTS))
22 echo "PROJECT_LIST=(${PROJECT_LIST[*]})" > $WORKSPACE/opnfv-projects.sh
23
24 for PROJECT in ${PROJECT_LIST[@]}; do
25   echo "> Cloning $PROJECT"
26   if [ ! -d "$PROJECT" ]; then
27     git clone "https://gerrit.opnfv.org/gerrit/$PROJECT.git"
28   else
29     pushd "$PROJECT" > /dev/null
30     git pull -f
31     popd > /dev/null
32   fi
33 done