X-Git-Url: https://gerrit.akraino.org/r/gitweb?p=ci-management.git;a=blobdiff_plain;f=jjb%2Fshell%2Frun_bluval.sh;h=d850f799e826df694caaeb926afb630fbcd02b5b;hp=76f87667c3efa91aaf001189d21441d1f22e4c54;hb=c99dd54898d212b4a85cf5a7fde98989eeb2c01b;hpb=c6db17ea4f9cfeaa710ffc8b95ee315d9f555a84 diff --git a/jjb/shell/run_bluval.sh b/jjb/shell/run_bluval.sh index 76f8766..d850f79 100755 --- a/jjb/shell/run_bluval.sh +++ b/jjb/shell/run_bluval.sh @@ -15,6 +15,7 @@ export PATH=$PATH:/home/jenkins/.local/bin cwd=$(pwd) current_user=$(whoami) is_optional="false" +pull="false" info () { logger -s -t "run_blu_val.info" "$*" @@ -49,6 +50,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!" @@ -65,7 +67,7 @@ error () { } # Get options from shell -while getopts "j:k:u:s:b:l:r:n:ov:" optchar; do +while getopts "j:k:u:s:b:l:r:n:opv:" optchar; do case "${optchar}" in j) cluster_master_ip=${OPTARG} ;; k) k8s_config_dir=${OPTARG} ;; @@ -75,6 +77,7 @@ while getopts "j:k:u:s:b:l:r:n:ov:" optchar; do n) blueprint_name=${OPTARG} ;; u) sh_user=${OPTARG} ;; o) is_optional="true" ;; + p) pull="true" ;; v) version=${OPTARG} ;; *) echo "Non-option argument: '-${OPTARG}'" >&2 usage @@ -107,7 +110,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 @@ -141,10 +144,10 @@ sed -i \ "$volumes_path" # create ssh_key_dir -mkdir -p $cwd/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 +cp "$ssh_key" "$cwd/ssh_key_dir/id_rsa" variables_path="$cwd/tests/variables.yaml" # update information in variables yaml @@ -161,14 +164,23 @@ if [ "$is_optional" == "true" ] || [ "$OPTIONAL" == "yes" ] then options+=" -o" fi - -printf 'ok / PASS /\nerror / FAIL /\n' > ./bluval/rules.txt +if [ "$pull" == "true" ] || [ "$PULL" == "yes" ] +then + options+=" -p" +fi 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 " @@ -183,11 +195,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 -