2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2016 Linux Foundation and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
12 export PATH=$PATH:/usr/local/bin/
14 DATE="$(date +%Y%m%d)"
16 declare -a PROJECT_LIST
17 EXCLUDE_PROJECTS="All-Projects|All-Users|securedlab"
18 CLONE_PATH="$WORKSPACE/opnfv-repos"
20 # Generate project list from gerrit
21 PROJECT_LIST=($(ssh -p 29418 jenkins-ci@gerrit.opnfv.org gerrit ls-projects | egrep -v $EXCLUDE_PROJECTS))
23 echo "Cloning all OPNFV repositories"
24 echo "------------------------------"
26 for PROJECT in "${PROJECT_LIST[@]}"; do
27 echo "> Cloning $PROJECT"
28 if [ ! -d "$CLONE_PATH/$PROJECT" ]; then
29 git clone "https://gerrit.opnfv.org/gerrit/$PROJECT.git" $CLONE_PATH/$PROJECT
31 pushd "$CLONE_PATH/$PROJECT" &>/dev/null
36 # Don't license scan kernel or qemu in kvmfornfv
37 if [ "$PROJECT" == "kvmfornfv" ]; then
38 rm -rf "$CLONE_PATH/$PROJECT/"{kernel,qemu}
42 echo "Finished cloning OPNFV repositories"
43 echo "-----------------------------------"
45 # Copy repos and clear git data
46 echo "Copying repos to $WORKSPACE/opnfv-archive and removing .git files"
47 cp -R $CLONE_PATH $WORKSPACE/opnfv-archive
48 find $WORKSPACE/opnfv-archive -type d -iname '.git' -exec rm -rf {} +
49 find $WORKSPACE/opnfv-archive -type f -iname '.git*' -exec rm -rf {} +
52 echo "Creating archive: opnfv-archive-$DATE.tar.gz"
53 echo "--------------------------------------"
55 tar -czf "opnfv-archive-$DATE.tar.gz" opnfv-archive && rm -rf opnfv-archive
56 echo "Archiving Complete."
58 echo "Uploading artifacts"
59 echo "--------------------------------------"
61 gsutil cp "$WORKSPACE/opnfv-archive-$DATE.tar.gz" \
62 "gs://opnfv-archive/opnfv-archive-$DATE.tar.gz" 2>&1
64 echo "https://storage.googleapis.com/opnfv-archive/opnfv-archive-$DATE.tar.gz" > archive-link.txt
66 rm -f opnfv-archive-$DATE.tar.gz