armband: add ci jobs
[releng.git] / jjb / armband / armband-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 if [[ "$JOB_NAME" =~ "merge" ]]; then
14     echo "Downloading http://$GS_URL/opnfv-gerrit-$GERRIT_CHANGE_NUMBER.properties"
15     # get the properties file for the Armband Fuel ISO built for a merged change
16     curl -s -o $WORKSPACE/latest.properties http://$GS_URL/opnfv-gerrit-$GERRIT_CHANGE_NUMBER.properties
17 else
18     # get the latest.properties file in order to get info regarding latest artifact
19     echo "Downloading http://$GS_URL/latest.properties"
20     curl -s -o $WORKSPACE/latest.properties http://$GS_URL/latest.properties
21 fi
22
23 # check if we got the file
24 # FIXME: the file is created even if it didn't exist on the host
25 #        We should check that the contents are sane
26 [[ -f latest.properties ]] || exit 1
27
28 # source the file so we get artifact metadata
29 source latest.properties
30
31 # echo the info about artifact that is used during the deployment
32 OPNFV_ARTIFACT=${OPNFV_ARTIFACT_URL/*\/}
33 echo "Using $OPNFV_ARTIFACT for deployment"
34
35 # using ISOs for verify & merge jobs from local storage will be enabled later
36 if [[ ! "$JOB_NAME" =~ (verify|merge) ]]; then
37     # check if we already have the ISO to avoid redownload
38     ISOSTORE="/iso_mount/opnfv_ci/${GIT_BRANCH##*/}"
39     if [[ -f "$ISOSTORE/$OPNFV_ARTIFACT" ]]; then
40         echo "ISO exists locally. Skipping the download and using the file from ISO store"
41         ln -s $ISOSTORE/$OPNFV_ARTIFACT $WORKSPACE/opnfv.iso
42         echo "--------------------------------------------------------"
43         echo
44         ls -al $WORKSPACE/opnfv.iso
45         echo
46         echo "--------------------------------------------------------"
47         echo "Done!"
48         exit 0
49     fi
50 fi
51
52 # log info to console
53 echo "Downloading the $INSTALLER_TYPE artifact using URL http://$OPNFV_ARTIFACT_URL"
54 echo "This could take some time..."
55 echo "--------------------------------------------------------"
56 echo
57
58 # download the file
59 curl -s -o $WORKSPACE/opnfv.iso http://$OPNFV_ARTIFACT_URL
60
61 # The file is always created, check that it is in fact an ISO image
62 [[ $(file $WORKSPACE/opnfv.iso) =~ ISO ]]
63
64 echo
65 echo "--------------------------------------------------------"
66 echo "Done!"