blob: f02b348065852c588a19c8ba101bba678358bbda [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
22# NOTES (fdegir): this script only works for
23# - infra/engine
24# - infra/provisioner/heat
25
26set -o nounset
27set -o errexit
28set -o pipefail
29
30# NOTE (fdegir): we need to remove $WORKSPACE and clone infra/engine repository
31# as infra/engine is what drives the deployment
32if [[ "$GERRIT_PROJECT" != "infra/engine" ]]; then
33 cd "$HOME" && /bin/rm -rf "$WORKSPACE"
34 echo "Info : Cloning infra/engine repository"
35 git clone -q https://gerrit.nordix.org/infra/engine.git "$WORKSPACE"
36 cd "$WORKSPACE"
37 # TODO (fdegir): this is temporarily here to develop the jobs
38 git fetch "https://gerrit.nordix.org/infra/engine" refs/changes/23/4823/18 && git checkout FETCH_HEAD
39fi
40
41# file to record change metadata
42 export CHANGE_METADATA_FILE="$WORKSPACE/change.properties"
43/bin/rm -f "$CHANGE_METADATA_FILE"
44
45echo "Info : Generating change metadata"
46
47# TODO (fdegir): this should match to the branch of the job for {stack}-verify jobs
48export STACK_VERSION=master
49
50# determine the project
51# this scripts is used by all engine repos so we need to determine what this change is for
52export ENGINE_COMPONENT="${GERRIT_PROJECT//*\//}"
53
54if [[ "$GERRIT_PROJECT" =~ /stack/ ]]; then
55 export STACK_TYPE="$ENGINE_COMPONENT"
56 echo "Info : Setting STACK_TYPE, STACK_VERSION and STACK_REFSPEC"
57 echo " STACK_TYPE=$STACK_TYPE"
58 echo " STACK_VERSION=$GERRIT_PATCHSET_REVISION"
59 echo " STACK_REFSPEC=$GERRIT_REFSPEC"
60 echo "STACK_TYPE=$STACK_TYPE" >> "$CHANGE_METADATA_FILE"
61 echo "STACK_VERSION=$GERRIT_PATCHSET_REVISION" >> "$CHANGE_METADATA_FILE"
62 echo "STACK_REFSPEC=$GERRIT_REFSPEC" >> "$CHANGE_METADATA_FILE"
63elif [[ "$GERRIT_PROJECT" =~ /installer/ ]]; then
64 case "${ENGINE_COMPONENT}" in
65 kolla)
66 export STACK_TYPE="openstack"
67 ;;
68 kubespray)
69 export STACK_TYPE="kubernetes"
70 ;;
71 oom)
72 export STACK_TYPE="onap"
73 ;;
74 *) echo "ERROR : Invalid engine component $ENGINE_COMPONENT"; exit 1;;
75 esac
76
77 echo "Info : Setting STACK_TYPE, STACK_VERSION and STACK_REFSPEC"
78 echo " STACK_TYPE=$STACK_TYPE"
79 echo " STACK_VERSION=$STACK_VERSION"
80 echo " NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_VERSION=$GERRIT_PATCHSET_REVISION"
81 echo " NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_REFSPEC=$GERRIT_REFSPEC"
82 echo "STACK_TYPE=$STACK_TYPE" >> "$CHANGE_METADATA_FILE"
83 echo "STACK_VERSION=$STACK_VERSION" >> "$CHANGE_METADATA_FILE"
84 echo "NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_VERSION=$GERRIT_PATCHSET_REVISION" >> "$CHANGE_METADATA_FILE"
85 echo "NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_REFSPEC=$GERRIT_REFSPEC" >> "$CHANGE_METADATA_FILE"
86else
87 export STACK_TYPE=kubernetes
88 export STACK_VERSION=$STACK_VERSION
89 echo "STACK_TYPE=kubernetes" >> "$CHANGE_METADATA_FILE"
90 echo "NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_VERSION=$GERRIT_PATCHSET_REVISION" >> "$CHANGE_METADATA_FILE"
91 echo "NORDIX_$(echo $ENGINE_COMPONENT | tr a-z A-Z)_REFSPEC=$GERRIT_REFSPEC" >> "$CHANGE_METADATA_FILE"
92fi
93
94# global vars
95export NORDIX_ARM_HTTPS_URL="https://artifactory.nordix.org/artifactory"
96export ARTIFACT_ARM_FOLDER="gerrit"
97export BUILD_IDENTIFIER=$GERRIT_CHANGE_NUMBER
98export INSTALLER_FILE="${STACK_TYPE}-ubuntu1804.bsx"
99export BUILD_ARTIFACTS="${STACK_TYPE}-ubuntu1804.bsx"
100export NORDIX_ARM_REPO="nordix-${STACK_TYPE}"
101export NORDIX_ARTIFACT_URL="$NORDIX_ARM_HTTPS_URL/$NORDIX_ARM_REPO/installer/oss/$ARTIFACT_ARM_FOLDER/$BUILD_IDENTIFIER"
102
103cat << EOF >> "$CHANGE_METADATA_FILE"
104BUILD_IDENTIFIER=$BUILD_IDENTIFIER
105BUILD_DATE=$(date '+%Y%m%d%H%M')
106BUILT_BY=$BUILD_URL
107CI_LOOP=$CI_LOOP
108ENGINE_SHA=$(git rev-parse HEAD)
109INSTALLER_FILE=${STACK_TYPE}-ubuntu1804.bsx
110BUILD_ARTIFACTS=${STACK_TYPE}-ubuntu1804.bsx
111NORDIX_ARM_REPO=nordix-${STACK_TYPE}
112NORDIX_ARTIFACT_URL=$NORDIX_ARTIFACT_URL
113EOF
114
115echo "Info : Change metadata"
116echo "-------------------------------------------------------------------------"
117cat "$CHANGE_METADATA_FILE"
118echo "-------------------------------------------------------------------------"
119
120# vim: set ts=2 sw=2 expandtab: