2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2018 SUSE 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 #----------------------------------------------------------------------
15 # This script is used by CI and executed by Jenkins jobs.
16 # You are not supposed to use this script manually if you don't know
18 #----------------------------------------------------------------------
20 # ensure GERRIT_TOPIC is set
21 GERRIT_TOPIC="${GERRIT_TOPIC:-''}"
22 # skip the healthcheck if the patch doesn't impact the deployment
23 if [[ "$GERRIT_TOPIC" =~ skip-verify|skip-deployment ]]; then
24 echo "Skipping the healthcheck!"
28 # if the scenario is external, we need to wipe WORKSPACE to place releng-xci there since
29 # the project where the scenario is coming from is cloned and the patch checked out to the
30 # xci/scenarios/$DEPLOY_SCENARIO to be synched on clean VM
31 # apart from that, we need releng-xci stuff in WORKSPACE for things to function correctly on Jenkins.
32 # if the change is coming to releng-xci, we don't need to do anything since the patch is checked
33 # out to the WORKSPACE anyways
34 if [[ $GERRIT_PROJECT != "releng-xci" ]]; then
35 cd $HOME && /bin/rm -rf $WORKSPACE
36 git clone https://gerrit.opnfv.org/gerrit/releng-xci $WORKSPACE && cd $WORKSPACE
37 chmod -R go-rwx $WORKSPACE/xci/scripts/vm
40 WORK_DIRECTORY=/tmp/$GERRIT_CHANGE_NUMBER/$DISTRO
41 /bin/rm -rf $WORK_DIRECTORY && mkdir -p $WORK_DIRECTORY
43 # if change is coming to releng-xci, continue as usual until that part is fixed as well
44 if [[ $GERRIT_PROJECT == "releng-xci" ]]; then
45 # save the scenario name into java properties file to be injected to downstream jobs via envInject
46 echo "Recording scenario name for downstream jobs"
47 echo "DEPLOY_SCENARIO=os-nosdn-nofeature" > $WORK_DIRECTORY/scenario.properties
51 # projects develop different scenarios and jobs need to know which scenario got the
52 # change under test so the jobs can deploy and test the right scenario.
53 # we need to fetch the change and look at the changeset to find out the scenario instead
54 # of hardcoding scenario per project.
56 git clone https://gerrit.opnfv.org/gerrit/$GERRIT_PROJECT $WORK_DIRECTORY/$GERRIT_PROJECT
57 cd $WORK_DIRECTORY/$GERRIT_PROJECT
58 git fetch https://gerrit.opnfv.org/gerrit/$GERRIT_PROJECT $GERRIT_REFSPEC && git checkout FETCH_HEAD
59 DEPLOY_SCENARIO=$(git diff HEAD^..HEAD --name-only | grep scenarios | sed -r 's/scenarios\/(.*?)\/.*/\1/' | uniq)
61 # ensure single scenario is impacted
62 if [[ $(echo $DEPLOY_SCENARIO | wc -w) != 1 ]]; then
63 echo "Change impacts multiple scenarios!"
64 echo "XCI doesn't support testing of changes that impact multiple scenarios currently."
65 echo "Please split your change into multiple different/dependent changes, each modifying single scenario."
69 # save the scenario name into java properties file to be injected to downstream jobs via envInject
70 echo "Recording scenario name '$DEPLOY_SCENARIO' for downstream jobs"
71 echo "DEPLOY_SCENARIO=$DEPLOY_SCENARIO" > $WORK_DIRECTORY/scenario.properties
73 # skip the deployment if the scenario is not supported on this distro
74 OPNFV_SCENARIO_REQUIREMENTS=$WORKSPACE/xci/opnfv-scenario-requirements.yml
75 if ! sed -n "/^- scenario: $DEPLOY_SCENARIO$/,/^$/p" $OPNFV_SCENARIO_REQUIREMENTS | grep -q $DISTRO; then
76 echo "# SKIPPED: Scenario $DEPLOY_SCENARIO is NOT supported on $DISTRO"