Remove functest-parser
[releng.git] / jjb / releng / opnfv-repo-archiver.sh
1 #!/bin/bash
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 ##############################################################################
10 set -o errexit
11 set -o pipefail
12 export PATH=$PATH:/usr/local/bin/
13
14 DATE="$(date +%Y%m%d)"
15
16 declare -a PROJECT_LIST
17 EXCLUDE_PROJECTS="All-Projects|All-Users|securedlab"
18 CLONE_PATH="$WORKSPACE/opnfv-repos"
19
20 # Generate project list from gerrit
21 PROJECT_LIST=($(ssh -p 29418 jenkins-ci@gerrit.opnfv.org gerrit ls-projects | egrep -v $EXCLUDE_PROJECTS))
22
23 echo "Cloning all OPNFV repositories"
24 echo "------------------------------"
25
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
30   else
31     pushd "$CLONE_PATH/$PROJECT" &>/dev/null
32     git pull -f
33     popd &> /dev/null
34   fi
35
36   # Don't license scan kernel or qemu in kvmfornfv
37   if [ "$PROJECT" == "kvmfornfv" ]; then
38     rm -rf "$CLONE_PATH/$PROJECT/"{kernel,qemu}
39   fi
40 done
41
42 echo "Finished cloning OPNFV repositories"
43 echo "-----------------------------------"
44
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 {} +
50
51 # Create archive
52 echo "Creating archive: opnfv-archive-$DATE.tar.gz"
53 echo "--------------------------------------"
54 cd $WORKSPACE
55 tar -czf "opnfv-archive-$DATE.tar.gz" opnfv-archive && rm -rf opnfv-archive
56 echo "Archiving Complete."
57
58 echo "Uploading artifacts"
59 echo "--------------------------------------"
60
61 gsutil cp "$WORKSPACE/opnfv-archive-$DATE.tar.gz" \
62     "gs://opnfv-archive/opnfv-archive-$DATE.tar.gz" 2>&1
63
64 echo "https://storage.googleapis.com/opnfv-archive/opnfv-archive-$DATE.tar.gz" > archive-link.txt
65
66 rm -f opnfv-archive-$DATE.tar.gz
67
68 echo "Finished"