87a9334b2435a680655ad6e07e5acecabe96d177
[releng.git] / jjb / compass4nfv / compass-upload-artifact.sh
1 #!/bin/bash
2 set -o nounset
3 set -o pipefail
4
5 # log info to console
6 echo "Uploading the $INSTALLER_TYPE artifact. This could take some time..."
7 echo "--------------------------------------------------------"
8 echo
9
10 if [[ "$BRANCH" == 'stable/danube' ]]; then
11     FILETYPE='iso'
12 else
13     FILETYPE='tar.gz'
14 fi
15 # source the opnfv.properties to get ARTIFACT_VERSION
16 source $BUILD_DIRECTORY/opnfv.properties
17
18 # clone releng repository
19 echo "Cloning releng repository..."
20 [ -d releng ] && rm -rf releng
21 git clone https://gerrit.opnfv.org/gerrit/releng $WORKSPACE/releng/ &> /dev/null
22 #this is where we import the siging key
23 if [ -f $WORKSPACE/releng/utils/gpg_import_key.sh ]; then
24   source $WORKSPACE/releng/utils/gpg_import_key.sh
25 fi
26
27 signiso () {
28 time gpg2 -vvv --batch --yes --no-tty \
29   --default-key opnfv-helpdesk@rt.linuxfoundation.org  \
30   --passphrase besteffort \
31   --detach-sig $BUILD_DIRECTORY/compass.$FILETYPE
32
33 gsutil cp $BUILD_DIRECTORY/compass.$FILETYPE.sig gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.$FILETYPE.sig
34 echo "ISO signature Upload Complete!"
35 }
36
37 signiso
38
39 # upload artifact and additional files to google storage
40 gsutil cp $BUILD_DIRECTORY/compass.$FILETYPE gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.$FILETYPE > gsutil.$FILETYPE.log 2>&1
41 gsutil cp $BUILD_DIRECTORY/opnfv.properties gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > gsutil.properties.log 2>&1
42 gsutil cp $BUILD_DIRECTORY/opnfv.properties gs://$GS_URL/latest.properties > gsutil.latest.log 2>&1
43
44 gsutil -m setmeta \
45     -h "Content-Type:text/html" \
46     -h "Cache-Control:private, max-age=0, no-transform" \
47     gs://$GS_URL/latest.properties \
48     gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > /dev/null 2>&1
49
50 gsutil -m setmeta \
51     -h "Cache-Control:private, max-age=0, no-transform" \
52     gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.$FILETYPE > /dev/null 2>&1
53
54 # disabled errexit due to gsutil setmeta complaints
55 #   BadRequestException: 400 Invalid argument
56 # check if we uploaded the file successfully to see if things are fine
57 gsutil ls gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.$FILETYPE > /dev/null 2>&1
58 if [[ $? -ne 0 ]]; then
59     echo "Problem while uploading artifact!"
60     echo "Check log $WORKSPACE/gsutil.$FILETYPE.log on the machine where this build is done."
61     exit 1
62 fi
63
64 echo
65 echo "--------------------------------------------------------"
66 echo "Done!"
67 echo "Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.$FILETYPE"