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 | 26 ++++++++++++++++++++++++++ 1 file changed, 26 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..36a70fd --- /dev/null +++ b/sparrow/0-package/read-config @@ -0,0 +1,26 @@ +#!/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 +} + +[[ -n "$my_email" && -n "$my_name" ]] && return +export_config_variables + +[[ -n "$my_email" && -n "$my_name" ]] && return +log_error "ENV $my_email or $my_name doesn't exist, please config $CCI_SRC/sparrow/setup.yaml" +exit 1