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 upload_logs() {
17 BIFROST_CONSOLE_LOG="${BUILD_URL}/consoleText"
18 BIFROST_GS_URL=${BIFROST_LOG_URL/http:/gs:}
20 echo "Uploading build logs to ${BIFROST_LOG_URL}"
22 echo "Uploading console output"
23 curl -s -L ${BIFROST_CONSOLE_LOG} | gsutil -q cp -Z - ${BIFROST_GS_URL}/build_log.txt
25 [[ ! -d ${WORKSPACE}/logs ]] && exit 0
27 pushd ${WORKSPACE}/logs/ &> /dev/null
29 echo "Compressing and uploading $x"
30 gsutil -q cp -Z ${x} ${BIFROST_GS_URL}/${x}
33 echo "Generating the landing page"
34 cat > index.html <<EOF
36 <h1>Build results for <a href=https://$GERRIT_NAME/#/c/$GERRIT_CHANGE_NUMBER/$GERRIT_PATCHSET_NUMBER>$GERRIT_NAME/$GERRIT_CHANGE_NUMBER/$GERRIT_PATCHSET_NUMBER</a></h1>
37 <h2>Job: $JOB_NAME</h2>
39 <li><a href=${BIFROST_LOG_URL}/build_log.txt>build_log.txt</a></li>
43 echo "<li><a href=${BIFROST_LOG_URL}/${x}>${x}</a></li>" >> index.html
46 cat >> index.html << EOF
51 gsutil -q cp index.html ${BIFROST_GS_URL}/index.html
58 function fix_ownership() {
59 if [ -z "${JOB_URL+x}" ]; then
60 echo "Not running as part of Jenkins. Handle the logs manually."
62 # Make sure cache exists
63 [[ ! -d ${HOME}/.cache ]] && mkdir ${HOME}/.cache
65 sudo chown -R jenkins:jenkins $WORKSPACE
66 sudo chown -R jenkins:jenkins ${HOME}/.cache
70 function cleanup_and_upload() {
77 # check distro to see if we support it
78 if [[ ! "$DISTRO" =~ (trusty|centos7|suse) ]]; then
79 echo "Distro $DISTRO is not supported!"
83 # remove previously cloned repos
84 sudo /bin/rm -rf /opt/bifrost /opt/puppet-infracloud /opt/stack /opt/releng
89 # clone all the repos first and checkout the patch afterwards
90 sudo git clone https://git.openstack.org/openstack/bifrost /opt/bifrost
91 sudo git clone https://git.openstack.org/openstack-infra/puppet-infracloud /opt/puppet-infracloud
92 sudo git clone https://gerrit.opnfv.org/gerrit/releng /opt/releng
96 sudo git fetch $PROJECT_REPO $GERRIT_REFSPEC && sudo git checkout FETCH_HEAD
98 # combine opnfv and upstream scripts/playbooks
99 sudo /bin/cp -rf /opt/releng/prototypes/bifrost/* /opt/bifrost/
101 # place bridge creation file on the right path
102 sudo mkdir -p /opt/puppet-infracloud/files/elements/infra-cloud-bridge/static/opt
103 sudo cp /opt/puppet-infracloud/templates/bifrost/create_bridge.py.erb /opt/puppet-infracloud/files/elements/infra-cloud-bridge/static/opt/create_bridge.py
105 # replace bridge name
106 sudo sed -i s/"<%= @bridge_name -%>"/br_opnfv/g /opt/puppet-infracloud/files/elements/infra-cloud-bridge/static/opt/create_bridge.py
108 # cleanup remnants of previous deployment
110 sudo -E ./scripts/destroy-env.sh
112 # provision 3 VMs; jumphost, controller, and compute
114 sudo -E ./scripts/test-bifrost-deployment.sh
116 # list the provisioned VMs