blob: 84b71467b17c9b25b4b9fc4cf8ab49e8ca390949 [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
36 export CHANGE_METADATA_FILE="$WORKSPACE/change.properties"
37/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
Fatih Degirmenci5db1c8f2020-07-02 07:59:51 +000052 case "${STACK_TYPE}" in
53 openstack)
54 echo "Info : Deploy scenario is overriden by job to $DEPLOY_SCENARIO"
55 ;;
56 kubernetes)
57 echo "Info : Deploy scenario is overriden by job to $DEPLOY_SCENARIO"
58 ;;
59 onap)
60 echo "Info : Deploy scenario is overriden by job to $DEPLOY_SCENARIO"
61 ;;
62 ironic)
63 export DEPLOY_SCENARIO="ubuntu1804"
64 ;;
65 *) echo "ERROR : Invalid stack $ENGINE_COMPONENT"; exit 1;;
66 esac
67
68 export STACK_VERSION="$GERRIT_BRANCH"
69
Fatih Degirmenci9f2d4dc2020-06-23 17:09:37 +000070 # log info to console
Fatih Degirmenci459c3482020-06-15 21:15:43 +000071 echo " STACK_TYPE=$STACK_TYPE"
Fatih Degirmenci5db1c8f2020-07-02 07:59:51 +000072 echo " DEPLOY_SCENARIO=$DEPLOY_SCENARIO"
Fatih Degirmenci459c3482020-06-15 21:15:43 +000073 echo " STACK_VERSION=$GERRIT_PATCHSET_REVISION"
74 echo " STACK_REFSPEC=$GERRIT_REFSPEC"
Fatih Degirmenci9f2d4dc2020-06-23 17:09:37 +000075
76 # record vars to properties file
Fatih Degirmenci459c3482020-06-15 21:15:43 +000077 echo "STACK_TYPE=$STACK_TYPE" >> "$CHANGE_METADATA_FILE"
Fatih Degirmenci5db1c8f2020-07-02 07:59:51 +000078 echo "DEPLOY_SCENARIO=$DEPLOY_SCENARIO" >> "$CHANGE_METADATA_FILE"
Fatih Degirmenci9f2d4dc2020-06-23 17:09:37 +000079 echo "STACK_VERSION=$STACK_VERSION" >> "$CHANGE_METADATA_FILE"
80 echo "STACK_REFSPEC=$STACK_REFSPEC" >> "$CHANGE_METADATA_FILE"
Fatih Degirmenci459c3482020-06-15 21:15:43 +000081elif [[ "$GERRIT_PROJECT" =~ /installer/ ]]; then
Fatih Degirmenci9f2d4dc2020-06-23 17:09:37 +000082 # set vars
Fatih Degirmenci459c3482020-06-15 21:15:43 +000083 case "${ENGINE_COMPONENT}" in
84 kolla)
85 export STACK_TYPE="openstack"
Fatih Degirmenci5db1c8f2020-07-02 07:59:51 +000086 echo "Info : Deploy scenario is overriden by job to $DEPLOY_SCENARIO"
Fatih Degirmenci459c3482020-06-15 21:15:43 +000087 ;;
88 kubespray)
89 export STACK_TYPE="kubernetes"
Fatih Degirmenci5db1c8f2020-07-02 07:59:51 +000090 echo "Info : Deploy scenario is overriden by job to $DEPLOY_SCENARIO"
Fatih Degirmenci459c3482020-06-15 21:15:43 +000091 ;;
92 oom)
93 export STACK_TYPE="onap"
Fatih Degirmenci5db1c8f2020-07-02 07:59:51 +000094 echo "Info : Deploy scenario is overriden by job to $DEPLOY_SCENARIO"
Fatih Degirmenci459c3482020-06-15 21:15:43 +000095 ;;
96 *) echo "ERROR : Invalid engine component $ENGINE_COMPONENT"; exit 1;;
97 esac
Fatih Degirmenci9f2d4dc2020-06-23 17:09:37 +000098 export STACK_VERSION="$GERRIT_BRANCH"
Fatih Degirmenci459c3482020-06-15 21:15:43 +000099
Fatih Degirmenci9f2d4dc2020-06-23 17:09:37 +0000100 # log info to console
Fatih Degirmenci459c3482020-06-15 21:15:43 +0000101 echo " STACK_TYPE=$STACK_TYPE"
Fatih Degirmenci5db1c8f2020-07-02 07:59:51 +0000102 echo " DEPLOY_SCENARIO=$DEPLOY_SCENARIO"
Fatih Degirmenci459c3482020-06-15 21:15:43 +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"
Fatih Degirmenci9f2d4dc2020-06-23 17:09:37 +0000106
107 # record vars to properties file
Fatih Degirmenci459c3482020-06-15 21:15:43 +0000108 echo "STACK_TYPE=$STACK_TYPE" >> "$CHANGE_METADATA_FILE"
Fatih Degirmenci5db1c8f2020-07-02 07:59:51 +0000109 echo "DEPLOY_SCENARIO=$DEPLOY_SCENARIO" >> "$CHANGE_METADATA_FILE"
Fatih Degirmenci459c3482020-06-15 21:15:43 +0000110 echo "STACK_VERSION=$STACK_VERSION" >> "$CHANGE_METADATA_FILE"
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"
113else
Fatih Degirmenci9f2d4dc2020-06-23 17:09:37 +0000114 # set vars
Fatih Degirmenci459c3482020-06-15 21:15:43 +0000115 export STACK_TYPE=kubernetes
Fatih Degirmenci9f2d4dc2020-06-23 17:09:37 +0000116 export STACK_VERSION=$GERRIT_BRANCH
117
118 # log info to console
119 echo " STACK_TYPE=$STACK_TYPE"
Fatih Degirmenci5db1c8f2020-07-02 07:59:51 +0000120 echo " DEPLOY_SCENARIO=$DEPLOY_SCENARIO"
Fatih Degirmenci9f2d4dc2020-06-23 17:09:37 +0000121 echo " STACK_VERSION=$STACK_VERSION"
122 echo " NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_VERSION=$GERRIT_PATCHSET_REVISION"
123 echo " NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_REFSPEC=$GERRIT_REFSPEC"
124
125 # record vars to properties file
Fatih Degirmenci5db1c8f2020-07-02 07:59:51 +0000126 echo "STACK_TYPE=$STACK_TYPE" >> "$CHANGE_METADATA_FILE"
127 echo "DEPLOY_SCENARIO=$DEPLOY_SCENARIO" >> "$CHANGE_METADATA_FILE"
Fatih Degirmencib112baf2020-06-23 09:32:32 +0000128 echo "STACK_VERSION=$STACK_VERSION" >> "$CHANGE_METADATA_FILE"
Fatih Degirmenci459c3482020-06-15 21:15:43 +0000129 echo "NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_VERSION=$GERRIT_PATCHSET_REVISION" >> "$CHANGE_METADATA_FILE"
130 echo "NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_REFSPEC=$GERRIT_REFSPEC" >> "$CHANGE_METADATA_FILE"
131fi
132
133# global vars
134export NORDIX_ARM_HTTPS_URL="https://artifactory.nordix.org/artifactory"
135export ARTIFACT_ARM_FOLDER="gerrit"
136export BUILD_IDENTIFIER=$GERRIT_CHANGE_NUMBER
Fatih Degirmencide51df02020-06-29 19:33:25 +0000137export INSTALLER_FILE="${STACK_TYPE}-${DISTRO}.bsx"
138export BUILD_ARTIFACTS="${STACK_TYPE}-${DISTRO}.bsx"
Fatih Degirmenci459c3482020-06-15 21:15:43 +0000139export NORDIX_ARM_REPO="nordix-${STACK_TYPE}"
140export NORDIX_ARTIFACT_URL="$NORDIX_ARM_HTTPS_URL/$NORDIX_ARM_REPO/installer/oss/$ARTIFACT_ARM_FOLDER/$BUILD_IDENTIFIER"
141
142cat << EOF >> "$CHANGE_METADATA_FILE"
143BUILD_IDENTIFIER=$BUILD_IDENTIFIER
144BUILD_DATE=$(date '+%Y%m%d%H%M')
145BUILT_BY=$BUILD_URL
Fatih Degirmencide51df02020-06-29 19:33:25 +0000146DISTRO=$DISTRO
Fatih Degirmenci459c3482020-06-15 21:15:43 +0000147CI_LOOP=$CI_LOOP
148ENGINE_SHA=$(git rev-parse HEAD)
149INSTALLER_FILE=${STACK_TYPE}-ubuntu1804.bsx
150BUILD_ARTIFACTS=${STACK_TYPE}-ubuntu1804.bsx
151NORDIX_ARM_REPO=nordix-${STACK_TYPE}
152NORDIX_ARTIFACT_URL=$NORDIX_ARTIFACT_URL
153EOF
154
155echo "Info : Change metadata"
156echo "-------------------------------------------------------------------------"
157cat "$CHANGE_METADATA_FILE"
158echo "-------------------------------------------------------------------------"
159
160# vim: set ts=2 sw=2 expandtab: