X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=jjb%2Fshell%2Frun_bluval.sh;h=fbe9aed6ceee8b6e4ae1765ba981adcb30762140;hb=98d358eb917ed9de44a6f71b8d90d58b3829cf97;hp=3bb4a6f4cca173563ea16ae1b136ea4c0748edf8;hpb=ecd7ed34ed2a547d8d64dddae12c1087754f7981;p=ci-management.git diff --git a/jjb/shell/run_bluval.sh b/jjb/shell/run_bluval.sh index 3bb4a6f..fbe9aed 100755 --- a/jjb/shell/run_bluval.sh +++ b/jjb/shell/run_bluval.sh @@ -49,6 +49,7 @@ usage() { verify_connectivity() { local ip=$1 info "Verifying connectivity to $ip..." + # shellcheck disable=SC2034 for i in $(seq 0 10); do if ping -c 1 -W 1 "$ip" > /dev/null; then info "$ip is reachable!" @@ -107,7 +108,7 @@ cluster_master_ip=${cluster_master_ip:-$CLUSTER_MASTER_IP} ssh_user=${sh_user:-$CLUSTER_SSH_USER} blueprint_layer=${blueprint_layer:-$LAYER} -if [ "$blueprint_layer" == "k8s" ] +if [ "$blueprint_layer" == "k8s" ] || [ -z "$blueprint_layer" ] then if [ -z "$cluster_master_ip" ] then @@ -131,8 +132,27 @@ then fi volumes_path="$cwd/bluval/volumes.yaml" -#update information in volumes yaml -sed -i -e "/kube_config_dir/{n; s@local: ''@local: '$k8s_config_dir'@}" -e "/blueprint_dir/{n; s@local: ''@local: '$cwd/bluval/'@}" -e "/results_dir/{n; s@local: ''@local: '$results_dir'@}" "$volumes_path" +# update information in volumes yaml +sed -i \ + -e "/ssh_key_dir/{n; s@local: ''@local: '$cwd/ssh_key_dir'@}" \ + -e "/kube_config_dir/{n; s@local: ''@local: '$k8s_config_dir'@}" \ + -e "/custom_variables_file/{n; s@local: ''@local: '$cwd/tests/variables.yaml'@}" \ + -e "/blueprint_dir/{n; s@local: ''@local: '$cwd/bluval/'@}" \ + -e "/results_dir/{n; s@local: ''@local: '$results_dir'@}" \ + "$volumes_path" + +# create ssh_key_dir +mkdir -p "$cwd/ssh_key_dir" + +# copy ssh_key in ssh_key_dir +cp "$ssh_key" "$cwd/ssh_key_dir/id_rsa" + +variables_path="$cwd/tests/variables.yaml" +# update information in variables yaml +sed -i \ + -e "s@host: [0-9]*.[0-9]*.[0-9]*.[0-9]*@host: $cluster_master_ip@" \ + -e "s@username: [A-Za-z0-9_]* @username: $ssh_user@" \ + "$variables_path" if [[ -n $blueprint_layer ]] then @@ -143,13 +163,18 @@ then options+=" -o" fi -printf 'ok / PASS /\nerror / FAIL /\n' > ./bluval/rules.txt - set +e -# even if the script fails we need to change the owner of results -# shellcheck disable=SC2086 -python3 bluval/blucon.py $options "$blueprint_name" +if python3 --version > /dev/null; then + # shellcheck disable=SC2086 + python3 bluval/blucon.py $options "$blueprint_name" +else + # shellcheck disable=SC2086 + VALIDATION_DIR="$WORKSPACE" RESULTS_DIR="$WORKSPACE/results" \ + bluval/blucon.sh $options "$blueprint_name" +fi +# even if the script fails we need to change the owner of results +# shellcheck disable=SC2181 if [ $? -ne 0 ]; then change_res_owner error "Bluval validation FAIL " @@ -164,11 +189,9 @@ else TIMESTAMP=$(date +'%Y%m%d-%H%M%S') NEXUS_URL=https://nexus.akraino.org/ NEXUS_PATH="${LAB_SILO}/bluval_results/${blueprint_name}/${VERSION}/${TIMESTAMP}" - BUILD_URL="${JENKINS_HOSTNAME}/job/${JOB_NAME}/${BUILD_NUMBER}/" zip -r results.zip ./results lftools deploy nexus-zip "$NEXUS_URL" logs "$NEXUS_PATH" results.zip rm results.zip fi rm -f ~/.netrc -