engine: Refactor kubernetes release jobs

Change-Id: I28c8f08d16687ffddc8f9d6f491ef04ec1b07d53
diff --git a/jjb/engine/scripts/generate-release-metadata.sh b/jjb/engine/scripts/generate-release-metadata.sh
new file mode 100755
index 0000000..c429895
--- /dev/null
+++ b/jjb/engine/scripts/generate-release-metadata.sh
@@ -0,0 +1,70 @@
+#!/bin/bash
+
+# ============LICENSE_START=======================================================
+#  Copyright (C) 2019 The Nordix Foundation. All rights reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+
+set -o nounset
+set -o errexit
+set -o pipefail
+
+# file to record release metadata
+export RELEASE_METADATA_FILE="$WORKSPACE/release.properties"
+/bin/rm -f "$RELEASE_METADATA_FILE" /tmp/release.properties
+
+echo "Info  : Generating release metadata"
+
+# global vars
+export NORDIX_ARM_HTTPS_URL="https://artifactory.nordix.org/artifactory"
+export ARTIFACT_ARM_FOLDER="release/${BRANCH}/stack"
+export BUILD_IDENTIFIER="$(date '+%Y%m%d%H%M')"
+export OFFLINE_INSTALLER_FILE="/tmp/${STACK_TYPE}-${BRANCH}-${DISTRO}.bsx"
+export BUILD_ARTIFACTS="/tmp/${STACK_TYPE}-${BRANCH}-${DISTRO}.bsx /tmp/offline-package.tgz $WORKSPACE/release.properties"
+export NORDIX_ARM_REPO="nordix-${STACK_TYPE}"
+export NORDIX_ARTIFACT_URL="$NORDIX_ARM_HTTPS_URL/$NORDIX_ARM_REPO/oss/$ARTIFACT_ARM_FOLDER/$BUILD_IDENTIFIER"
+
+cat << EOF >> "$RELEASE_METADATA_FILE"
+BUILD_IDENTIFIER=$BUILD_IDENTIFIER
+BUILD_DATE=$BUILD_IDENTIFIER
+BRANCH=$BRANCH
+RELEASE_JOB=$BUILD_URL
+DISTRO=$DISTRO
+DEPLOY_SCENARIO=$DEPLOY_SCENARIO
+CI_LOOP=$CI_LOOP
+STACK_TYPE=$STACK_TYPE
+STACK_VERSION=$STACK_VERSION
+PROMOTE_STACK=$PROMOTE_STACK
+NORDIX_ENGINE_VERSION=$NORDIX_ENGINE_VERSION
+NORDIX_KUBESPRAY_VERSION=$NORDIX_KUBESPRAY_VERSION
+NORDIX_BIFROST_VERSION=$NORDIX_BIFROST_VERSION
+NORDIX_HEAT_VERSION=$NORDIX_HEAT_VERSION
+OFFLINE_INSTALLER_FILE=$OFFLINE_INSTALLER_FILE
+BUILD_ARTIFACTS=$BUILD_ARTIFACTS
+NORDIX_ARM_REPO=nordix-${STACK_TYPE}
+NORDIX_ARTIFACT_URL=$NORDIX_ARTIFACT_URL
+EOF
+
+echo "Info  : Release metadata"
+echo "-------------------------------------------------------------------------"
+cat "$RELEASE_METADATA_FILE"
+echo "-------------------------------------------------------------------------"
+
+# NOTE (fdegir): release.properties file will be included in the tarball if the packaging
+# is run for release purposes
+/bin/cp -f $RELEASE_METADATA_FILE /tmp/release.properties
+
+# vim: set ts=2 sw=2 expandtab: