Fatih Degirmenci | 459c348 | 2020-06-15 21:15:43 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 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 |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 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. |
| 17 | # |
| 18 | # SPDX-License-Identifier: Apache-2.0 |
| 19 | # ============LICENSE_END========================================================= |
| 20 | |
| 21 | |
Fatih Degirmenci | 459c348 | 2020-06-15 21:15:43 +0000 | [diff] [blame] | 22 | set -o nounset |
| 23 | set -o errexit |
| 24 | set -o pipefail |
| 25 | |
| 26 | # NOTE (fdegir): we need to remove $WORKSPACE and clone infra/engine repository |
| 27 | # as infra/engine is what drives the deployment |
| 28 | if [[ "$GERRIT_PROJECT" != "infra/engine" ]]; then |
| 29 | cd "$HOME" && /bin/rm -rf "$WORKSPACE" |
| 30 | echo "Info : Cloning infra/engine repository" |
| 31 | git clone -q https://gerrit.nordix.org/infra/engine.git "$WORKSPACE" |
| 32 | cd "$WORKSPACE" |
Fatih Degirmenci | 459c348 | 2020-06-15 21:15:43 +0000 | [diff] [blame] | 33 | fi |
| 34 | |
| 35 | # file to record change metadata |
Fatih Degirmenci | 929e8b0 | 2020-07-02 20:29:39 +0000 | [diff] [blame^] | 36 | export CHANGE_METADATA_FILE="$WORKSPACE/change.properties" |
Fatih Degirmenci | 459c348 | 2020-06-15 21:15:43 +0000 | [diff] [blame] | 37 | /bin/rm -f "$CHANGE_METADATA_FILE" |
| 38 | |
| 39 | echo "Info : Generating change metadata" |
| 40 | |
Fatih Degirmenci | 459c348 | 2020-06-15 21:15:43 +0000 | [diff] [blame] | 41 | # determine the project |
| 42 | # this scripts is used by all engine repos so we need to determine what this change is for |
| 43 | export ENGINE_COMPONENT="${GERRIT_PROJECT//*\//}" |
| 44 | |
Fatih Degirmenci | 9f2d4dc | 2020-06-23 17:09:37 +0000 | [diff] [blame] | 45 | echo "Info : Setting STACK_TYPE and STACK_VERSION" |
Fatih Degirmenci | 459c348 | 2020-06-15 21:15:43 +0000 | [diff] [blame] | 46 | if [[ "$GERRIT_PROJECT" =~ /stack/ ]]; then |
Fatih Degirmenci | 9f2d4dc | 2020-06-23 17:09:37 +0000 | [diff] [blame] | 47 | # set vars |
Fatih Degirmenci | 459c348 | 2020-06-15 21:15:43 +0000 | [diff] [blame] | 48 | export STACK_TYPE="$ENGINE_COMPONENT" |
Fatih Degirmenci | 9f2d4dc | 2020-06-23 17:09:37 +0000 | [diff] [blame] | 49 | export STACK_VERSION="$GERRIT_PATCHSET_REVISION" |
| 50 | export STACK_REFSPEC="$GERRIT_REFSPEC" |
| 51 | |
| 52 | # log info to console |
Fatih Degirmenci | 459c348 | 2020-06-15 21:15:43 +0000 | [diff] [blame] | 53 | echo " STACK_TYPE=$STACK_TYPE" |
Fatih Degirmenci | 5db1c8f | 2020-07-02 07:59:51 +0000 | [diff] [blame] | 54 | echo " DEPLOY_SCENARIO=$DEPLOY_SCENARIO" |
Fatih Degirmenci | 459c348 | 2020-06-15 21:15:43 +0000 | [diff] [blame] | 55 | echo " STACK_VERSION=$GERRIT_PATCHSET_REVISION" |
| 56 | echo " STACK_REFSPEC=$GERRIT_REFSPEC" |
Fatih Degirmenci | 9f2d4dc | 2020-06-23 17:09:37 +0000 | [diff] [blame] | 57 | |
| 58 | # record vars to properties file |
Fatih Degirmenci | 459c348 | 2020-06-15 21:15:43 +0000 | [diff] [blame] | 59 | echo "STACK_TYPE=$STACK_TYPE" >> "$CHANGE_METADATA_FILE" |
Fatih Degirmenci | 5db1c8f | 2020-07-02 07:59:51 +0000 | [diff] [blame] | 60 | echo "DEPLOY_SCENARIO=$DEPLOY_SCENARIO" >> "$CHANGE_METADATA_FILE" |
Fatih Degirmenci | 9f2d4dc | 2020-06-23 17:09:37 +0000 | [diff] [blame] | 61 | echo "STACK_VERSION=$STACK_VERSION" >> "$CHANGE_METADATA_FILE" |
| 62 | echo "STACK_REFSPEC=$STACK_REFSPEC" >> "$CHANGE_METADATA_FILE" |
Fatih Degirmenci | 459c348 | 2020-06-15 21:15:43 +0000 | [diff] [blame] | 63 | elif [[ "$GERRIT_PROJECT" =~ /installer/ ]]; then |
Fatih Degirmenci | 9f2d4dc | 2020-06-23 17:09:37 +0000 | [diff] [blame] | 64 | # set vars |
Fatih Degirmenci | 459c348 | 2020-06-15 21:15:43 +0000 | [diff] [blame] | 65 | case "${ENGINE_COMPONENT}" in |
| 66 | kolla) |
| 67 | export STACK_TYPE="openstack" |
Fatih Degirmenci | 5db1c8f | 2020-07-02 07:59:51 +0000 | [diff] [blame] | 68 | echo "Info : Deploy scenario is overriden by job to $DEPLOY_SCENARIO" |
Fatih Degirmenci | 459c348 | 2020-06-15 21:15:43 +0000 | [diff] [blame] | 69 | ;; |
| 70 | kubespray) |
| 71 | export STACK_TYPE="kubernetes" |
Fatih Degirmenci | 5db1c8f | 2020-07-02 07:59:51 +0000 | [diff] [blame] | 72 | echo "Info : Deploy scenario is overriden by job to $DEPLOY_SCENARIO" |
Fatih Degirmenci | 459c348 | 2020-06-15 21:15:43 +0000 | [diff] [blame] | 73 | ;; |
| 74 | oom) |
| 75 | export STACK_TYPE="onap" |
Fatih Degirmenci | 5db1c8f | 2020-07-02 07:59:51 +0000 | [diff] [blame] | 76 | echo "Info : Deploy scenario is overriden by job to $DEPLOY_SCENARIO" |
Fatih Degirmenci | 459c348 | 2020-06-15 21:15:43 +0000 | [diff] [blame] | 77 | ;; |
| 78 | *) echo "ERROR : Invalid engine component $ENGINE_COMPONENT"; exit 1;; |
| 79 | esac |
Fatih Degirmenci | 9f2d4dc | 2020-06-23 17:09:37 +0000 | [diff] [blame] | 80 | export STACK_VERSION="$GERRIT_BRANCH" |
Fatih Degirmenci | 459c348 | 2020-06-15 21:15:43 +0000 | [diff] [blame] | 81 | |
Fatih Degirmenci | 9f2d4dc | 2020-06-23 17:09:37 +0000 | [diff] [blame] | 82 | # log info to console |
Fatih Degirmenci | 459c348 | 2020-06-15 21:15:43 +0000 | [diff] [blame] | 83 | echo " STACK_TYPE=$STACK_TYPE" |
Fatih Degirmenci | 5db1c8f | 2020-07-02 07:59:51 +0000 | [diff] [blame] | 84 | echo " DEPLOY_SCENARIO=$DEPLOY_SCENARIO" |
Fatih Degirmenci | 459c348 | 2020-06-15 21:15:43 +0000 | [diff] [blame] | 85 | echo " STACK_VERSION=$STACK_VERSION" |
| 86 | echo " NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_VERSION=$GERRIT_PATCHSET_REVISION" |
| 87 | echo " NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_REFSPEC=$GERRIT_REFSPEC" |
Fatih Degirmenci | 9f2d4dc | 2020-06-23 17:09:37 +0000 | [diff] [blame] | 88 | |
| 89 | # record vars to properties file |
Fatih Degirmenci | 459c348 | 2020-06-15 21:15:43 +0000 | [diff] [blame] | 90 | echo "STACK_TYPE=$STACK_TYPE" >> "$CHANGE_METADATA_FILE" |
Fatih Degirmenci | 5db1c8f | 2020-07-02 07:59:51 +0000 | [diff] [blame] | 91 | echo "DEPLOY_SCENARIO=$DEPLOY_SCENARIO" >> "$CHANGE_METADATA_FILE" |
Fatih Degirmenci | 459c348 | 2020-06-15 21:15:43 +0000 | [diff] [blame] | 92 | echo "STACK_VERSION=$STACK_VERSION" >> "$CHANGE_METADATA_FILE" |
| 93 | echo "NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_VERSION=$GERRIT_PATCHSET_REVISION" >> "$CHANGE_METADATA_FILE" |
| 94 | echo "NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_REFSPEC=$GERRIT_REFSPEC" >> "$CHANGE_METADATA_FILE" |
| 95 | else |
Fatih Degirmenci | 9f2d4dc | 2020-06-23 17:09:37 +0000 | [diff] [blame] | 96 | # set vars |
Fatih Degirmenci | 459c348 | 2020-06-15 21:15:43 +0000 | [diff] [blame] | 97 | export STACK_TYPE=kubernetes |
Fatih Degirmenci | 9f2d4dc | 2020-06-23 17:09:37 +0000 | [diff] [blame] | 98 | export STACK_VERSION=$GERRIT_BRANCH |
| 99 | |
| 100 | # log info to console |
| 101 | echo " STACK_TYPE=$STACK_TYPE" |
Fatih Degirmenci | 5db1c8f | 2020-07-02 07:59:51 +0000 | [diff] [blame] | 102 | echo " DEPLOY_SCENARIO=$DEPLOY_SCENARIO" |
Fatih Degirmenci | 9f2d4dc | 2020-06-23 17:09:37 +0000 | [diff] [blame] | 103 | echo " STACK_VERSION=$STACK_VERSION" |
| 104 | echo " NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_VERSION=$GERRIT_PATCHSET_REVISION" |
| 105 | echo " NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_REFSPEC=$GERRIT_REFSPEC" |
| 106 | |
| 107 | # record vars to properties file |
Fatih Degirmenci | 5db1c8f | 2020-07-02 07:59:51 +0000 | [diff] [blame] | 108 | echo "STACK_TYPE=$STACK_TYPE" >> "$CHANGE_METADATA_FILE" |
| 109 | echo "DEPLOY_SCENARIO=$DEPLOY_SCENARIO" >> "$CHANGE_METADATA_FILE" |
Fatih Degirmenci | b112baf | 2020-06-23 09:32:32 +0000 | [diff] [blame] | 110 | echo "STACK_VERSION=$STACK_VERSION" >> "$CHANGE_METADATA_FILE" |
Fatih Degirmenci | 459c348 | 2020-06-15 21:15:43 +0000 | [diff] [blame] | 111 | echo "NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_VERSION=$GERRIT_PATCHSET_REVISION" >> "$CHANGE_METADATA_FILE" |
| 112 | echo "NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_REFSPEC=$GERRIT_REFSPEC" >> "$CHANGE_METADATA_FILE" |
| 113 | fi |
| 114 | |
| 115 | # global vars |
| 116 | export NORDIX_ARM_HTTPS_URL="https://artifactory.nordix.org/artifactory" |
| 117 | export ARTIFACT_ARM_FOLDER="gerrit" |
| 118 | export BUILD_IDENTIFIER=$GERRIT_CHANGE_NUMBER |
Fatih Degirmenci | de51df0 | 2020-06-29 19:33:25 +0000 | [diff] [blame] | 119 | export INSTALLER_FILE="${STACK_TYPE}-${DISTRO}.bsx" |
| 120 | export BUILD_ARTIFACTS="${STACK_TYPE}-${DISTRO}.bsx" |
Fatih Degirmenci | 459c348 | 2020-06-15 21:15:43 +0000 | [diff] [blame] | 121 | export NORDIX_ARM_REPO="nordix-${STACK_TYPE}" |
| 122 | export NORDIX_ARTIFACT_URL="$NORDIX_ARM_HTTPS_URL/$NORDIX_ARM_REPO/installer/oss/$ARTIFACT_ARM_FOLDER/$BUILD_IDENTIFIER" |
| 123 | |
| 124 | cat << EOF >> "$CHANGE_METADATA_FILE" |
| 125 | BUILD_IDENTIFIER=$BUILD_IDENTIFIER |
| 126 | BUILD_DATE=$(date '+%Y%m%d%H%M') |
| 127 | BUILT_BY=$BUILD_URL |
Fatih Degirmenci | de51df0 | 2020-06-29 19:33:25 +0000 | [diff] [blame] | 128 | DISTRO=$DISTRO |
Fatih Degirmenci | 459c348 | 2020-06-15 21:15:43 +0000 | [diff] [blame] | 129 | CI_LOOP=$CI_LOOP |
| 130 | ENGINE_SHA=$(git rev-parse HEAD) |
| 131 | INSTALLER_FILE=${STACK_TYPE}-ubuntu1804.bsx |
| 132 | BUILD_ARTIFACTS=${STACK_TYPE}-ubuntu1804.bsx |
| 133 | NORDIX_ARM_REPO=nordix-${STACK_TYPE} |
| 134 | NORDIX_ARTIFACT_URL=$NORDIX_ARTIFACT_URL |
| 135 | EOF |
| 136 | |
| 137 | echo "Info : Change metadata" |
| 138 | echo "-------------------------------------------------------------------------" |
| 139 | cat "$CHANGE_METADATA_FILE" |
| 140 | echo "-------------------------------------------------------------------------" |
| 141 | |
| 142 | # vim: set ts=2 sw=2 expandtab: |