Add latest gate jobs
[releng.git] / jjb / barometer / barometer-upload-artifact.sh
1 #!/bin/bash
2 set -o nounset
3 set -o pipefail
4
5 RPM_LIST=$WORKSPACE/ci/utilities/rpms_list
6 RPM_WORKDIR=$WORKSPACE/rpmbuild
7 RPM_DIR=$RPM_WORKDIR/RPMS/x86_64/
8 cd $WORKSPACE/
9
10 # source the opnfv.properties to get ARTIFACT_VERSION
11 source $WORKSPACE/opnfv.properties
12
13 # Check if all the appropriate RPMs were generated
14 echo "Checking if all the Barometer RPMs were created"
15 echo "-----------------------------------------------"
16 echo
17
18 if [ -d $RPM_DIR ]
19 then
20     ls $RPM_DIR > list_of_gen_pack
21 else
22     echo "Can't access folder $RPM_DIR with rpm packages"
23     echo "Barometer nightly build FAILED"
24     exit 1
25 fi
26
27 for PACKAGENAME in `cat $RPM_LIST`
28 do
29         if ! grep -q $PACKAGENAME list_of_gen_pack
30         then
31                 echo "$PACKAGENAME is missing"
32                 echo "Barometer nightly build FAILED"
33                 exit 2
34         fi
35 done
36
37 #remove the file you no longer need.
38 rm list_of_gen_pack
39
40 echo "Uploading the barometer RPMs to artifacts.opnfv.org"
41 echo "---------------------------------------------------"
42 echo
43
44 gsutil -m cp -r $RPM_DIR/* gs://$OPNFV_ARTIFACT_URL > $WORKSPACE/gsutil.log 2>&1
45
46 # Check if the RPMs were pushed
47 gsutil ls gs://$OPNFV_ARTIFACT_URL > /dev/null 2>&1
48 if [[ $? -ne 0 ]]; then
49   echo "Problem while uploading barometer RPMs to gs://$OPNFV_ARTIFACT_URL!"
50   echo "Check log $WORKSPACE/gsutil.log on the appropriate build server"
51   exit 1
52 else
53   # upload property files only if build is successful
54   gsutil cp $WORKSPACE/opnfv.properties gs://$OPNFV_ARTIFACT_URL/opnfv.properties > gsutil.properties.log 2>&1
55   gsutil cp $WORKSPACE/opnfv.properties gs://$GS_URL/latest.properties > gsutil.latest.log 2>&1
56 fi
57
58 gsutil -m setmeta \
59     -h "Cache-Control:private, max-age=0, no-transform" \
60     gs://$OPNFV_ARTIFACT_URL/*.rpm > /dev/null 2>&1
61
62 gsutil -m setmeta \
63     -h "Content-Type:text/html" \
64     -h "Cache-Control:private, max-age=0, no-transform" \
65     gs://$GS_URL/latest.properties \
66     gs://$OPNFV_ARTIFACT_URL/opnfv.properties > /dev/null 2>&1
67
68 echo
69 echo "--------------------------------------------------------"
70 echo "Done!"
71 echo "Artifact is available at $OPNFV_ARTIFACT_URL"
72
73 #cleanup the RPM repo from the build machine.
74 rm -rf $RPM_WORKDIR