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 ##############################################################################
14 trap cleanup_and_upload EXIT
16 function fix_ownership() {
17 if [ -z "${JOB_URL+x}" ]; then
18 echo "Not running as part of Jenkins. Handle the logs manually."
20 # Make sure cache exists
21 [[ ! -d ${HOME}/.cache ]] && mkdir ${HOME}/.cache
23 sudo chown -R jenkins:jenkins $WORKSPACE
24 sudo chown -R jenkins:jenkins ${HOME}/.cache
28 function cleanup_and_upload() {
34 # check distro to see if we support it
35 if [[ ! "$DISTRO" =~ (xenial|centos7|suse) ]]; then
36 echo "Distro $DISTRO is not supported!"
40 # remove previously cloned repos
41 sudo /bin/rm -rf /opt/bifrost /opt/openstack-ansible /opt/releng-xci /opt/functest
46 # ensure the versions to checkout are set
47 export OPENSTACK_BIFROST_VERSION=${OPENSTACK_BIFROST_VERSION:-master}
48 export OPNFV_RELENG_VERSION=${OPNFV_RELENG_VERSION:-master}
52 echo "***********************************************************************"
54 echo "* Provision OpenStack Nodes *"
56 echo " bifrost version: $OPENSTACK_BIFROST_VERSION"
57 echo " releng version: $OPNFV_RELENG_VERSION"
59 echo "***********************************************************************"
62 # clone the repos and checkout the versions
63 sudo git clone --quiet https://git.openstack.org/openstack/bifrost /opt/bifrost
64 cd /opt/bifrost && sudo git checkout --quiet $OPENSTACK_BIFROST_VERSION
65 echo "xci: using bifrost commit"
66 git show --oneline -s --pretty=format:'%h - %s (%cr) <%an>'
68 sudo git clone --quiet https://gerrit.opnfv.org/gerrit/releng-xci /opt/releng-xci
69 cd /opt/releng-xci && sudo git checkout --quiet $OPNFV_RELENG_VERSION
70 echo "xci: using releng commit"
71 git show --oneline -s --pretty=format:'%h - %s (%cr) <%an>'
74 source "$WORKSPACE/xci/config/${XCI_FLAVOR}-vars"
76 # combine opnfv and upstream scripts/playbooks
77 sudo /bin/cp -rf /opt/releng-xci/bifrost/* /opt/bifrost/
79 # cleanup remnants of previous deployment
81 sudo -E ./scripts/destroy-env.sh
83 # provision VMs for the flavor
85 ./scripts/bifrost-provision.sh
87 # list the provisioned VMs
93 echo "OpenStack nodes are provisioned!"
94 # here we have to do something in order to capture what was the working sha1
95 # hardcoding stuff for the timebeing
98 BIFROST_GIT_SHA1=$(git rev-parse HEAD)
102 echo "***********************************************************************"
103 echo "* BIFROST SHA1 TO PIN *"
105 echo " $BIFROST_GIT_SHA1"
107 echo "***********************************************************************"