3 # ============LICENSE_START=======================================================
4 # Copyright (C) 2019 The Nordix Foundation. All rights reserved.
5 # ================================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
18 # SPDX-License-Identifier: Apache-2.0
19 # ============LICENSE_END=========================================================
25 # this function processes commit message to determine the impacted scenario
26 # using the input provided by the committer.
28 # provisioner type, installer type and scenario should be placed at the beginning of
29 # lines separately and the format of the entry in commit message is as below
31 # provisioner-type: <provisioner type>
32 # installer-type: <installer type>
33 # deploy-scenario: <scenario name>
37 # provisioner-type: bifrost
38 # installer-type: kubespray
39 # deploy-scenario: k8-calico-nofeature
40 function override_installer_scenario() {
41 echo "Info: Processing $GERRIT_PROJECT patchset $GERRIT_REFSPEC to determine the provisioner, installer and, scenario"
43 COMMIT_MESSAGE=$(git show -s --format=%B)
45 if [[ "$COMMIT_MESSAGE" =~ "provisioner-type:" ]]; then
46 # we support heat as well so ensure we capture it
47 export PROVISIONER_TYPE=$(echo "$COMMIT_MESSAGE" | grep '^provisioner-type:' | cut -d":" -f2 | sed 's/\s*//g')
49 # default is almost always bifrost
50 export PROVISIONER_TYPE=bifrost
53 if [[ "$COMMIT_MESSAGE" =~ "deploy-scenario:" && "$COMMIT_MESSAGE" =~ "installer-type:" ]]; then
54 export INSTALLER_TYPE=$(echo "$COMMIT_MESSAGE" | grep '^installer-type:' | cut -d":" -f2 | sed 's/\s*//g')
55 export DEPLOY_SCENARIO=$(echo "$COMMIT_MESSAGE" | grep '^deploy-scenario:' | cut -d":" -f2 | sed 's/\s*//g')
58 echo "Info: Installer type or deploy scenario is not specified."
59 echo "Info: Falling back to programmatically determining them."
63 # this function will process the changed files to determine the impacted scenario
64 # if it is no specified by the committer. only one scenario per change should be
66 # TODO: this is not implented yet.
67 function determine_scenario() {
68 # for infra/engine repo, we set INSTALLER_TYPE and DEPLOY_SCENARIO to their defaults
69 echo "Info: Processing $GERRIT_PROJECT patchset $GERRIT_REFSPEC"
70 if [[ "$GERRIT_PROJECT" == "infra/engine" ]]; then
71 echo "Info: Setting INSTALLER_TYPE and DEPLOY_SCENARIO to defaults for project $GERRIT_PROJECT patchset $GERRIT_REFSPEC"
72 export PROVISIONER_TYPE=bifrost
73 export INSTALLER_TYPE=kubespray
74 export DEPLOY_SCENARIO=k8-calico-nofeature
78 COMMIT_MESSAGE=$(git show -s --format=%B)
79 echo "Info: Not implemented!"
84 function write_change_metadata() {
85 echo "Info: Writing change metadata to $WORKSPACE/change.properties"
86 cat << EOF > $WORKSPACE/change.properties
87 PROJECT_GIT_URL=$GIT_BASE_HTTPS/$GERRIT_PROJECT
88 PROVISIONER_TYPE=$PROVISIONER_TYPE
89 INSTALLER_TYPE=$INSTALLER_TYPE
90 DEPLOY_SCENARIO=$DEPLOY_SCENARIO
91 GERRIT_PATCHSET_REVISION=$GERRIT_PATCHSET_REVISION
92 GERRIT_REFSPEC=$GERRIT_REFSPEC
95 echo "Info: Content of change.properties"
96 echo "-------------------------------------------------------------------------"
97 cat $WORKSPACE/change.properties
98 echo "-------------------------------------------------------------------------"
100 # need to exit here to ensure we don't go further while determining scenario
104 echo "Info: Determining the provisioner, installer, and scenario"
106 declare -a PROVISIONER_TYPE
107 declare -a INSTALLER_TYPE
108 declare -a DEPLOY_SCENARIO
110 override_installer_scenario
113 # vim: set ts=2 sw=2 expandtab: