xci: Introduce XCI_LOOP variable to control what to do properly
[releng.git] / jjb / xci / xci-deploy.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 nounset
12 set -o pipefail
13
14 cd $WORKSPACE/prototypes/xci
15
16 # for daily jobs, we want to use working versions
17 # for periodic jobs, we will use whatever is set in the job, probably master
18 if [[ "$XCI_LOOP" == "daily" ]]; then
19     # source pinned-vars to get releng version
20     source ./config/pinned-versions
21
22     # checkout the version
23     git checkout -q $OPNFV_RELENG_VERSION
24     echo "Info: Using $OPNFV_RELENG_VERSION"
25 elif [[ "$XCI_LOOP" == "periodic" ]]; then
26     echo "Info: Using $OPNFV_RELENG_VERSION"
27 fi
28
29 # this is just an example to give the idea about what we need to do
30 # so ignore this part for the timebeing as we need to adjust xci-deploy.sh
31 # to take this into account while deploying anyways
32 # clone openstack-ansible
33 # stable/ocata already use pinned versions so this is only valid for master
34 if [[ "$XCI_LOOP" == "periodic" && "$OPENSTACK_OSA_VERSION" == "master" ]]; then
35     cd $WORKSPACE
36     # get the url to openstack-ansible git
37     source ./config/env-vars
38     echo "Info: Capture the ansible role requirement versions before doing anything"
39     git clone -q $OPENSTACK_OSA_GIT_URL
40     cd openstack-ansible
41     cat ansible-role-requirements.yml | while IFS= read -r line
42     do
43         if [[ $line =~ "src:" ]]; then
44             repo_url=$(echo $line | awk {'print $2'})
45             repo_sha1=$(git ls-remote $repo_url $OPENSTACK_OSA_VERSION | awk {'print $1'})
46         fi
47         echo "$line" | sed -e "s|master|$repo_sha1|" >> opnfv-ansible-role-requirements.yml
48     done
49     echo "Info: SHA1s of ansible role requirements"
50     echo "-------------------------------------------------------------------------"
51     cat opnfv-ansible-role-requirements.yml
52     echo "-------------------------------------------------------------------------"
53 fi
54
55 # proceed with the deployment
56 cd $WORKSPACE/prototypes/xci
57 sudo -E ./xci-deploy.sh
58
59 # if we arrived here without failing, it means we have something we can pin
60 # this is again here to show the intention
61 cd $WORKSPACE/openstack-ansible
62 OSA_GIT_SHA1=$(git rev-parse HEAD)
63
64 # log some info
65 echo -e "\n"
66 echo "***********************************************************************"
67 echo "*                          OSA SHA1 TO PIN                            *"
68 echo "*                                                                     *"
69 echo "    $OSA_GIT_SHA1"
70 echo "*                                                                     *"
71 echo "***********************************************************************"
72
73 echo -e "\n"