Add fuel@x86 and fuel@arm support
[releng.git] / jjb / daisy4nfv / daisy4nfv-upload-artifact.sh
1 #!/bin/bash
2 ##############################################################################
3 # Copyright (c) 2016 ZTE Coreporation and others.
4 # hu.zhijiang@zte.com.cn
5 # sun.jing22@zte.com.cn
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
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 # source the opnfv.properties to get ARTIFACT_VERSION
21 source $WORKSPACE/opnfv.properties
22
23 importkey () {
24 # clone releng repository
25 echo "Cloning releng repository..."
26 [ -d releng ] && rm -rf releng
27 git clone https://gerrit.opnfv.org/gerrit/releng $WORKSPACE/releng/ &> /dev/null
28 #this is where we import the siging key
29 if [ -f $WORKSPACE/releng/utils/gpg_import_key.sh ]; then
30   source $WORKSPACE/releng/utils/gpg_import_key.sh
31 fi
32 }
33
34 signbin () {
35 gpg2 -vvv --batch --yes --no-tty \
36   --default-key opnfv-helpdesk@rt.linuxfoundation.org  \
37   --passphrase besteffort \
38   --detach-sig $BUILD_DIRECTORY/opnfv-$OPNFV_ARTIFACT_VERSION.bin
39
40 gsutil cp $BUILD_DIRECTORY/opnfv-$OPNFV_ARTIFACT_VERSION.bin.sig gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.bin.sig
41 echo "BIN signature Upload Complete!"
42 }
43
44 uploadbin () {
45 # log info to console
46 echo "Uploading $INSTALLER_TYPE artifact. This could take some time..."
47 echo
48
49 cd $WORKSPACE
50 # upload artifact and additional files to google storage
51 gsutil cp $BUILD_DIRECTORY/opnfv-$OPNFV_ARTIFACT_VERSION.bin \
52     gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.bin > gsutil.bin.log 2>&1
53 gsutil cp $WORKSPACE/opnfv.properties \
54     gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > gsutil.properties.log 2>&1
55 if [[ ! "$JOB_NAME" =~ (verify|merge) ]]; then
56     gsutil cp $WORKSPACE/opnfv.properties \
57     gs://$GS_URL/latest.properties > gsutil.latest.log 2>&1
58 elif [[ "$JOB_NAME" =~ "merge" ]]; then
59     echo "Uploaded Daisy4nfv BIN for a merged change"
60 fi
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://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > /dev/null 2>&1
67
68 gsutil -m setmeta \
69     -h "Cache-Control:private, max-age=0, no-transform" \
70     gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.bin > /dev/null 2>&1
71
72 # disabled errexit due to gsutil setmeta complaints
73 #   BadRequestException: 400 Invalid argument
74 # check if we uploaded the file successfully to see if things are fine
75 gsutil ls gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.bin > /dev/null 2>&1
76 if [[ $? -ne 0 ]]; then
77     echo "Problem while uploading artifact!"
78     echo "Check log $WORKSPACE/gsutil.bin.log on the machine where this build is done."
79     exit 1
80 fi
81
82 echo "Done!"
83 echo
84 echo "--------------------------------------------------------"
85 echo
86 echo "Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.bin"
87 echo
88 echo "--------------------------------------------------------"
89 echo
90 }
91
92 importkey
93 signbin
94 uploadbin