New external network for ericsson-pod2
[releng.git] / jjb / fuel / fuel-upload-artifact.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2016 Ericsson AB 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 nounset
11 set -o pipefail
12
13 # check if we built something
14 if [ -f $WORKSPACE/.noupload ]; then
15     echo "Nothing new to upload. Exiting."
16     /bin/rm -f $WORKSPACE/.noupload
17     exit 0
18 fi
19
20 # log info to console
21 echo
22 echo "Uploading the $INSTALLER_TYPE artifact. This could take some time..."
23 echo
24
25 # source the opnfv.properties to get ARTIFACT_VERSION
26 source $WORKSPACE/opnfv.properties
27
28 # upload artifact and additional files to google storage
29 gsutil cp $BUILD_DIRECTORY/opnfv-$OPNFV_ARTIFACT_VERSION.iso \
30     gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso > gsutil.iso.log 2>&1
31 gsutil cp $WORKSPACE/opnfv.properties \
32     gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > gsutil.properties.log 2>&1
33 if [[ ! "$JOB_NAME" =~ (verify|merge) ]]; then
34     gsutil cp $WORKSPACE/opnfv.properties \
35     gs://$GS_URL/latest.properties > gsutil.latest.log 2>&1
36 elif [[ "$JOB_NAME" =~ "merge" ]]; then
37     echo "Uploaded Fuel ISO for a merged change"
38 fi
39
40 gsutil -m setmeta \
41     -h "Content-Type:text/html" \
42     -h "Cache-Control:private, max-age=0, no-transform" \
43     gs://$GS_URL/latest.properties \
44     gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > /dev/null 2>&1
45
46 gsutil -m setmeta \
47     -h "Cache-Control:private, max-age=0, no-transform" \
48     gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso > /dev/null 2>&1
49
50 # disabled errexit due to gsutil setmeta complaints
51 #   BadRequestException: 400 Invalid argument
52 # check if we uploaded the file successfully to see if things are fine
53 gsutil ls gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso > /dev/null 2>&1
54 if [[ $? -ne 0 ]]; then
55     echo "Problem while uploading artifact!"
56     echo "Check log $WORKSPACE/gsutil.iso.log on the machine where this build is done."
57     exit 1
58 fi
59
60 echo "Done!"
61 echo
62 echo "--------------------------------------------------------"
63 echo
64 echo "Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
65 echo
66 echo "--------------------------------------------------------"
67 echo