blob: 219c186a52809c0a8c5ae1b2bc48960033b1e0aa [file] [log] [blame]
Fatih Degirmenci459c3482020-06-15 21:15:43 +00001#!/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 Degirmenci459c3482020-06-15 21:15:43 +000022set -o nounset
23set -o errexit
24set -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
28if [[ "$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 Degirmenci459c3482020-06-15 21:15:43 +000033fi
34
35# file to record change metadata
Fatih Degirmenci929e8b02020-07-02 20:29:39 +000036export CHANGE_METADATA_FILE="$WORKSPACE/change.properties"
Fatih Degirmenci459c3482020-06-15 21:15:43 +000037/bin/rm -f "$CHANGE_METADATA_FILE"
38
39echo "Info : Generating change metadata"
40
Fatih Degirmenci459c3482020-06-15 21:15:43 +000041# determine the project
42# this scripts is used by all engine repos so we need to determine what this change is for
43export ENGINE_COMPONENT="${GERRIT_PROJECT//*\//}"
44
Fatih Degirmenci9f2d4dc2020-06-23 17:09:37 +000045echo "Info : Setting STACK_TYPE and STACK_VERSION"
Fatih Degirmenci459c3482020-06-15 21:15:43 +000046if [[ "$GERRIT_PROJECT" =~ /stack/ ]]; then
Fatih Degirmenci9f2d4dc2020-06-23 17:09:37 +000047 # set vars
Fatih Degirmenci459c3482020-06-15 21:15:43 +000048 export STACK_TYPE="$ENGINE_COMPONENT"
Fatih Degirmenci9f2d4dc2020-06-23 17:09:37 +000049 export STACK_VERSION="$GERRIT_PATCHSET_REVISION"
50 export STACK_REFSPEC="$GERRIT_REFSPEC"
51
52 # log info to console
Fatih Degirmenci459c3482020-06-15 21:15:43 +000053 echo " STACK_TYPE=$STACK_TYPE"
Fatih Degirmenci5db1c8f2020-07-02 07:59:51 +000054 echo " DEPLOY_SCENARIO=$DEPLOY_SCENARIO"
Fatih Degirmenci459c3482020-06-15 21:15:43 +000055 echo " STACK_VERSION=$GERRIT_PATCHSET_REVISION"
56 echo " STACK_REFSPEC=$GERRIT_REFSPEC"
Fatih Degirmenci9f2d4dc2020-06-23 17:09:37 +000057
58 # record vars to properties file
Fatih Degirmenci459c3482020-06-15 21:15:43 +000059 echo "STACK_TYPE=$STACK_TYPE" >> "$CHANGE_METADATA_FILE"
Fatih Degirmenci5db1c8f2020-07-02 07:59:51 +000060 echo "DEPLOY_SCENARIO=$DEPLOY_SCENARIO" >> "$CHANGE_METADATA_FILE"
Fatih Degirmenci9f2d4dc2020-06-23 17:09:37 +000061 echo "STACK_VERSION=$STACK_VERSION" >> "$CHANGE_METADATA_FILE"
62 echo "STACK_REFSPEC=$STACK_REFSPEC" >> "$CHANGE_METADATA_FILE"
Fatih Degirmenci459c3482020-06-15 21:15:43 +000063elif [[ "$GERRIT_PROJECT" =~ /installer/ ]]; then
Fatih Degirmenci9f2d4dc2020-06-23 17:09:37 +000064 # set vars
Fatih Degirmenci459c3482020-06-15 21:15:43 +000065 case "${ENGINE_COMPONENT}" in
66 kolla)
67 export STACK_TYPE="openstack"
Fatih Degirmenci5db1c8f2020-07-02 07:59:51 +000068 echo "Info : Deploy scenario is overriden by job to $DEPLOY_SCENARIO"
Fatih Degirmenci459c3482020-06-15 21:15:43 +000069 ;;
70 kubespray)
71 export STACK_TYPE="kubernetes"
Fatih Degirmenci5db1c8f2020-07-02 07:59:51 +000072 echo "Info : Deploy scenario is overriden by job to $DEPLOY_SCENARIO"
Fatih Degirmenci459c3482020-06-15 21:15:43 +000073 ;;
74 oom)
75 export STACK_TYPE="onap"
Fatih Degirmenci5db1c8f2020-07-02 07:59:51 +000076 echo "Info : Deploy scenario is overriden by job to $DEPLOY_SCENARIO"
Fatih Degirmenci459c3482020-06-15 21:15:43 +000077 ;;
78 *) echo "ERROR : Invalid engine component $ENGINE_COMPONENT"; exit 1;;
79 esac
Fatih Degirmenci9f2d4dc2020-06-23 17:09:37 +000080 export STACK_VERSION="$GERRIT_BRANCH"
Fatih Degirmenci459c3482020-06-15 21:15:43 +000081
Fatih Degirmenci9f2d4dc2020-06-23 17:09:37 +000082 # log info to console
Fatih Degirmenci459c3482020-06-15 21:15:43 +000083 echo " STACK_TYPE=$STACK_TYPE"
Fatih Degirmenci5db1c8f2020-07-02 07:59:51 +000084 echo " DEPLOY_SCENARIO=$DEPLOY_SCENARIO"
Fatih Degirmenci459c3482020-06-15 21:15:43 +000085 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 Degirmenci9f2d4dc2020-06-23 17:09:37 +000088
89 # record vars to properties file
Fatih Degirmenci459c3482020-06-15 21:15:43 +000090 echo "STACK_TYPE=$STACK_TYPE" >> "$CHANGE_METADATA_FILE"
Fatih Degirmenci5db1c8f2020-07-02 07:59:51 +000091 echo "DEPLOY_SCENARIO=$DEPLOY_SCENARIO" >> "$CHANGE_METADATA_FILE"
Fatih Degirmenci459c3482020-06-15 21:15:43 +000092 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"
95else
Fatih Degirmenci9f2d4dc2020-06-23 17:09:37 +000096 # set vars
Fatih Degirmenci459c3482020-06-15 21:15:43 +000097 export STACK_TYPE=kubernetes
Fatih Degirmenci9f2d4dc2020-06-23 17:09:37 +000098 export STACK_VERSION=$GERRIT_BRANCH
99
100 # log info to console
101 echo " STACK_TYPE=$STACK_TYPE"
Fatih Degirmenci5db1c8f2020-07-02 07:59:51 +0000102 echo " DEPLOY_SCENARIO=$DEPLOY_SCENARIO"
Fatih Degirmenci9f2d4dc2020-06-23 17:09:37 +0000103 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 Degirmenci5db1c8f2020-07-02 07:59:51 +0000108 echo "STACK_TYPE=$STACK_TYPE" >> "$CHANGE_METADATA_FILE"
109 echo "DEPLOY_SCENARIO=$DEPLOY_SCENARIO" >> "$CHANGE_METADATA_FILE"
Fatih Degirmencib112baf2020-06-23 09:32:32 +0000110 echo "STACK_VERSION=$STACK_VERSION" >> "$CHANGE_METADATA_FILE"
Fatih Degirmenci459c3482020-06-15 21:15:43 +0000111 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"
113fi
114
115# global vars
116export NORDIX_ARM_HTTPS_URL="https://artifactory.nordix.org/artifactory"
117export ARTIFACT_ARM_FOLDER="gerrit"
118export BUILD_IDENTIFIER=$GERRIT_CHANGE_NUMBER
Fatih Degirmencide51df02020-06-29 19:33:25 +0000119export INSTALLER_FILE="${STACK_TYPE}-${DISTRO}.bsx"
120export BUILD_ARTIFACTS="${STACK_TYPE}-${DISTRO}.bsx"
Fatih Degirmenci459c3482020-06-15 21:15:43 +0000121export NORDIX_ARM_REPO="nordix-${STACK_TYPE}"
122export NORDIX_ARTIFACT_URL="$NORDIX_ARM_HTTPS_URL/$NORDIX_ARM_REPO/installer/oss/$ARTIFACT_ARM_FOLDER/$BUILD_IDENTIFIER"
123
124cat << EOF >> "$CHANGE_METADATA_FILE"
125BUILD_IDENTIFIER=$BUILD_IDENTIFIER
126BUILD_DATE=$(date '+%Y%m%d%H%M')
127BUILT_BY=$BUILD_URL
Fatih Degirmencide51df02020-06-29 19:33:25 +0000128DISTRO=$DISTRO
Fatih Degirmenci459c3482020-06-15 21:15:43 +0000129CI_LOOP=$CI_LOOP
130ENGINE_SHA=$(git rev-parse HEAD)
131INSTALLER_FILE=${STACK_TYPE}-ubuntu1804.bsx
132BUILD_ARTIFACTS=${STACK_TYPE}-ubuntu1804.bsx
133NORDIX_ARM_REPO=nordix-${STACK_TYPE}
134NORDIX_ARTIFACT_URL=$NORDIX_ARTIFACT_URL
135EOF
136
137echo "Info : Change metadata"
138echo "-------------------------------------------------------------------------"
139cat "$CHANGE_METADATA_FILE"
140echo "-------------------------------------------------------------------------"
141
142# vim: set ts=2 sw=2 expandtab: