if ENV $my_email or $my_name doesn't exist, export config yaml variables firstly, if not config sparrow/setup.yaml, call log_error() and exit.
Signed-off-by: Liu Yinsi liuyinsi@163.com --- sparrow/0-package/read-config | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 sparrow/0-package/read-config
diff --git a/sparrow/0-package/read-config b/sparrow/0-package/read-config new file mode 100755 index 0000000..62bb1aa --- /dev/null +++ b/sparrow/0-package/read-config @@ -0,0 +1,28 @@ +#!/bin/bash +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. +# export config info setup.yaml server_ip, my_email, my_name. + +. $CCI_SRC/lib/log.sh + +export_config_variables() +{ + mkdir -p /etc/compass-ci/ + cp -a $CCI_SRC/sparrow/setup.yaml /etc/compass-ci/setup.yaml + + options=( server_ip my_name my_email ) + + for option in ${options[@]} + do + export $option=$(awk -F ": " '/^'$option'/ {print $2}' /etc/compass-ci/setup.yaml) + done +} + +if [ -z "$my_email" ] || [ -z "$my_name" ]; then + export_config_variables +fi + +if [ -z "$my_email" ] || [ -z "$my_name" ]; then + log_error "ENV $my_email or $my_name doesn't exist, please config $CCI_SRC/sparrow/setup.yaml" + exit 1 +fi