[fuel] Disable iso download for master branch
[releng.git] / jjb / fuel / fuel-download-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 errexit
11 set -o pipefail
12
13 # disable Fuel ISO download for master branch
14 [[ "$BRANCH" == 'master' ]] && exit 0
15
16 # use proxy url to replace the nomral URL, for googleusercontent.com will be blocked randomly
17 [[ "$NODE_NAME" =~ (zte) ]] && GS_URL=${GS_BASE_PROXY%%/*}/$GS_URL
18
19 if [[ "$JOB_NAME" =~ "merge" ]]; then
20     echo "Downloading http://$GS_URL/opnfv-gerrit-$GERRIT_CHANGE_NUMBER.properties"
21     # get the properties file for the Fuel ISO built for a merged change
22     curl -L -s -o $WORKSPACE/latest.properties http://$GS_URL/opnfv-gerrit-$GERRIT_CHANGE_NUMBER.properties
23 else
24     # get the latest.properties file in order to get info regarding latest artifact
25     echo "Downloading http://$GS_URL/latest.properties"
26     curl -L -s -o $WORKSPACE/latest.properties http://$GS_URL/latest.properties
27 fi
28
29 # check if we got the file
30 [[ -f $WORKSPACE/latest.properties ]] || exit 1
31
32 # source the file so we get artifact metadata
33 source $WORKSPACE/latest.properties
34
35 # echo the info about artifact that is used during the deployment
36 OPNFV_ARTIFACT=${OPNFV_ARTIFACT_URL/*\/}
37 echo "Using $OPNFV_ARTIFACT for deployment"
38
39 # using ISOs for verify & merge jobs from local storage will be enabled later
40 if [[ ! "$JOB_NAME" =~ (verify|merge) ]]; then
41     # check if we already have the ISO to avoid redownload
42     ISOSTORE="/iso_mount/opnfv_ci/${BRANCH##*/}"
43     if [[ -f "$ISOSTORE/$OPNFV_ARTIFACT" ]]; then
44         echo "ISO exists locally. Skipping the download and using the file from ISO store"
45         ln -s $ISOSTORE/$OPNFV_ARTIFACT $WORKSPACE/opnfv.iso
46         echo "--------------------------------------------------------"
47         echo
48         ls -al $WORKSPACE/opnfv.iso
49         echo
50         echo "--------------------------------------------------------"
51         echo "Done!"
52         exit 0
53     fi
54 fi
55
56 [[ "$NODE_NAME" =~ (zte) ]] && OPNFV_ARTIFACT_URL=${GS_BASE_PROXY%%/*}/$OPNFV_ARTIFACT_URL
57
58 # log info to console
59 echo "Downloading the $INSTALLER_TYPE artifact using URL http://$OPNFV_ARTIFACT_URL"
60 echo "This could take some time..."
61 echo "--------------------------------------------------------"
62 echo
63
64 # download the file
65 curl -L -s -o $WORKSPACE/opnfv.iso http://$OPNFV_ARTIFACT_URL > gsutil.iso.log 2>&1
66
67 # list the file
68 ls -al $WORKSPACE/opnfv.iso
69
70 echo
71 echo "--------------------------------------------------------"
72 echo "Done!"