From c410baebe3541363602e48ed5eef4cbbea0cf651 Mon Sep 17 00:00:00 2001 From: Duo Zhang Date: Sat, 9 Oct 2021 09:43:43 +0800 Subject: [PATCH] HBASE-26339 SshPublisher will skip uploading artifacts if the build is failure (#3736) Signed-off-by: Josh Elser Signed-off-by: Nick Dimiduk Signed-off-by: Sean Busbey --- dev-support/Jenkinsfile | 182 +++++++++++++++++++++------------ dev-support/Jenkinsfile_GitHub | 69 +++++++++---- 2 files changed, 167 insertions(+), 84 deletions(-) diff --git a/dev-support/Jenkinsfile b/dev-support/Jenkinsfile index 8194787b2e6..85d2c2a4bb1 100644 --- a/dev-support/Jenkinsfile +++ b/dev-support/Jenkinsfile @@ -210,7 +210,7 @@ pipeline { rm -rf "${OUTPUT_DIR}" && mkdir "${OUTPUT_DIR}" echo '(x) {color:red}-1 general checks{color}' >"${OUTPUT_DIR}/commentfile" echo "-- Something went wrong running this stage, please [check relevant console output|${BUILD_URL}/console]." >> "${OUTPUT_DIR}/commentfile" -''' + ''' unstash 'yetus' // since we have a new node definition we need to re-do the scm checkout dir('component') { @@ -222,20 +222,30 @@ pipeline { "${BASEDIR}/dev-support/gather_machine_environment.sh" "${OUTPUT_DIR_RELATIVE}/machine" echo "got the following saved stats in '${OUTPUT_DIR_RELATIVE}/machine'" ls -lh "${OUTPUT_DIR_RELATIVE}/machine" -''' - // TODO roll this into the hbase_nightly_yetus script - sh '''#!/usr/bin/env bash - set -e - declare -i status=0 - if "${BASEDIR}/dev-support/hbase_nightly_yetus.sh" ; then - echo '(/) {color:green}+1 general checks{color}' > "${OUTPUT_DIR}/commentfile" - else - echo '(x) {color:red}-1 general checks{color}' > "${OUTPUT_DIR}/commentfile" - status=1 - fi - echo "-- For more information [see general report|${BUILD_URL}General_20Nightly_20Build_20Report/]" >> "${OUTPUT_DIR}/commentfile" - exit "${status}" ''' + // TODO roll this into the hbase_nightly_yetus script + script { + def ret = sh( + returnStatus: true, + script: '''#!/usr/bin/env bash + set -e + declare -i status=0 + if "${BASEDIR}/dev-support/hbase_nightly_yetus.sh" ; then + echo '(/) {color:green}+1 general checks{color}' > "${OUTPUT_DIR}/commentfile" + else + echo '(x) {color:red}-1 general checks{color}' > "${OUTPUT_DIR}/commentfile" + status=1 + fi + echo "-- For more information [see general report|${BUILD_URL}General_20Nightly_20Build_20Report/]" >> "${OUTPUT_DIR}/commentfile" + exit "${status}" + ''' + ) + if (ret != 0) { + // mark the build as UNSTABLE instead of FAILURE, to avoid skipping the later publish of + // test output. See HBASE-26339 for more details. + currentBuild.result = 'UNSTABLE' + } + } } post { always { @@ -278,7 +288,7 @@ pipeline { rm -rf "${OUTPUT_DIR}" && mkdir "${OUTPUT_DIR}" echo '(x) {color:red}-1 jdk7 checks{color}' >"${OUTPUT_DIR}/commentfile" echo "-- Something went wrong running this stage, please [check relevant console output|${BUILD_URL}/console]." >> "${OUTPUT_DIR}/commentfile" -''' + ''' unstash 'yetus' dir('component') { checkout scm @@ -289,19 +299,29 @@ pipeline { "${BASEDIR}/dev-support/gather_machine_environment.sh" "${OUTPUT_DIR_RELATIVE}/machine" echo "got the following saved stats in '${OUTPUT_DIR_RELATIVE}/machine'" ls -lh "${OUTPUT_DIR_RELATIVE}/machine" -''' - sh '''#!/usr/bin/env bash - set -e - declare -i status=0 - if "${BASEDIR}/dev-support/hbase_nightly_yetus.sh" ; then - echo '(/) {color:green}+1 jdk7 checks{color}' > "${OUTPUT_DIR}/commentfile" - else - echo '(x) {color:red}-1 jdk7 checks{color}' > "${OUTPUT_DIR}/commentfile" - status=1 - fi - echo "-- For more information [see jdk7 report|${BUILD_URL}/JDK7_20Nightly_20Build_20Report/]" >> "${OUTPUT_DIR}/commentfile" - exit "${status}" ''' + script { + def ret = sh( + returnStatus: true, + script: '''#!/usr/bin/env bash + set -e + declare -i status=0 + if "${BASEDIR}/dev-support/hbase_nightly_yetus.sh" ; then + echo '(/) {color:green}+1 jdk7 checks{color}' > "${OUTPUT_DIR}/commentfile" + else + echo '(x) {color:red}-1 jdk7 checks{color}' > "${OUTPUT_DIR}/commentfile" + status=1 + fi + echo "-- For more information [see jdk7 report|${BUILD_URL}/JDK7_20Nightly_20Build_20Report/]" >> "${OUTPUT_DIR}/commentfile" + exit "${status}" + ''' + ) + if (ret != 0) { + // mark the build as UNSTABLE instead of FAILURE, to avoid skipping the later publish of + // test output. See HBASE-26339 for more details. + currentBuild.result = 'UNSTABLE' + } + } } post { always { @@ -378,7 +398,7 @@ pipeline { rm -rf "${OUTPUT_DIR}" && mkdir "${OUTPUT_DIR}" echo '(x) {color:red}-1 jdk8 hadoop2 checks{color}' >"${OUTPUT_DIR}/commentfile" echo "-- Something went wrong running this stage, please [check relevant console output|${BUILD_URL}/console]." >> "${OUTPUT_DIR}/commentfile" -''' + ''' unstash 'yetus' dir('component') { checkout scm @@ -389,19 +409,29 @@ pipeline { "${BASEDIR}/dev-support/gather_machine_environment.sh" "${OUTPUT_DIR_RELATIVE}/machine" echo "got the following saved stats in '${OUTPUT_DIR_RELATIVE}/machine'" ls -lh "${OUTPUT_DIR_RELATIVE}/machine" -''' - sh '''#!/usr/bin/env bash - set -e - declare -i status=0 - if "${BASEDIR}/dev-support/hbase_nightly_yetus.sh" ; then - echo '(/) {color:green}+1 jdk8 hadoop2 checks{color}' > "${OUTPUT_DIR}/commentfile" - else - echo '(x) {color:red}-1 jdk8 hadoop2 checks{color}' > "${OUTPUT_DIR}/commentfile" - status=1 - fi - echo "-- For more information [see jdk8 (hadoop2) report|${BUILD_URL}JDK8_20Nightly_20Build_20Report_20_28Hadoop2_29/]" >> "${OUTPUT_DIR}/commentfile" - exit "${status}" ''' + script { + def ret = sh( + returnStatus: true, + script: '''#!/usr/bin/env bash + set -e + declare -i status=0 + if "${BASEDIR}/dev-support/hbase_nightly_yetus.sh" ; then + echo '(/) {color:green}+1 jdk8 hadoop2 checks{color}' > "${OUTPUT_DIR}/commentfile" + else + echo '(x) {color:red}-1 jdk8 hadoop2 checks{color}' > "${OUTPUT_DIR}/commentfile" + status=1 + fi + echo "-- For more information [see jdk8 (hadoop2) report|${BUILD_URL}JDK8_20Nightly_20Build_20Report_20_28Hadoop2_29/]" >> "${OUTPUT_DIR}/commentfile" + exit "${status}" + ''' + ) + if (ret != 0) { + // mark the build as UNSTABLE instead of FAILURE, to avoid skipping the later publish of + // test output. See HBASE-26339 for more details. + currentBuild.result = 'UNSTABLE' + } + } } post { always { @@ -482,7 +512,7 @@ pipeline { rm -rf "${OUTPUT_DIR}" && mkdir "${OUTPUT_DIR}" echo '(x) {color:red}-1 jdk8 hadoop3 checks{color}' >"${OUTPUT_DIR}/commentfile" echo "-- Something went wrong running this stage, please [check relevant console output|${BUILD_URL}/console]." >> "${OUTPUT_DIR}/commentfile" -''' + ''' unstash 'yetus' dir('component') { checkout scm @@ -493,19 +523,29 @@ pipeline { "${BASEDIR}/dev-support/gather_machine_environment.sh" "${OUTPUT_DIR_RELATIVE}/machine" echo "got the following saved stats in '${OUTPUT_DIR_RELATIVE}/machine'" ls -lh "${OUTPUT_DIR_RELATIVE}/machine" -''' - sh '''#!/usr/bin/env bash - set -e - declare -i status=0 - if "${BASEDIR}/dev-support/hbase_nightly_yetus.sh" ; then - echo '(/) {color:green}+1 jdk8 hadoop3 checks{color}' > "${OUTPUT_DIR}/commentfile" - else - echo '(x) {color:red}-1 jdk8 hadoop3 checks{color}' > "${OUTPUT_DIR}/commentfile" - status=1 - fi - echo "-- For more information [see jdk8 (hadoop3) report|${BUILD_URL}JDK8_20Nightly_20Build_20Report_20_28Hadoop3_29/]" >> "${OUTPUT_DIR}/commentfile" - exit "${status}" ''' + script { + def ret = sh( + returnStatus: true, + script: '''#!/usr/bin/env bash + set -e + declare -i status=0 + if "${BASEDIR}/dev-support/hbase_nightly_yetus.sh" ; then + echo '(/) {color:green}+1 jdk8 hadoop3 checks{color}' > "${OUTPUT_DIR}/commentfile" + else + echo '(x) {color:red}-1 jdk8 hadoop3 checks{color}' > "${OUTPUT_DIR}/commentfile" + status=1 + fi + echo "-- For more information [see jdk8 (hadoop3) report|${BUILD_URL}JDK8_20Nightly_20Build_20Report_20_28Hadoop3_29/]" >> "${OUTPUT_DIR}/commentfile" + exit "${status}" + ''' + ) + if (ret != 0) { + // mark the build as UNSTABLE instead of FAILURE, to avoid skipping the later publish of + // test output. See HBASE-26339 for more details. + currentBuild.result = 'UNSTABLE' + } + } } post { always { @@ -588,7 +628,7 @@ pipeline { rm -rf "${OUTPUT_DIR}" && mkdir "${OUTPUT_DIR}" echo '(x) {color:red}-1 jdk11 hadoop3 checks{color}' >"${OUTPUT_DIR}/commentfile" echo "-- Something went wrong running this stage, please [check relevant console output|${BUILD_URL}/console]." >> "${OUTPUT_DIR}/commentfile" -''' + ''' unstash 'yetus' dir('component') { checkout scm @@ -599,19 +639,29 @@ pipeline { "${BASEDIR}/dev-support/gather_machine_environment.sh" "${OUTPUT_DIR_RELATIVE}/machine" echo "got the following saved stats in '${OUTPUT_DIR_RELATIVE}/machine'" ls -lh "${OUTPUT_DIR_RELATIVE}/machine" -''' - sh '''#!/usr/bin/env bash - set -e - declare -i status=0 - if "${BASEDIR}/dev-support/hbase_nightly_yetus.sh" ; then - echo '(/) {color:green}+1 jdk11 hadoop3 checks{color}' > "${OUTPUT_DIR}/commentfile" - else - echo '(x) {color:red}-1 jdk11 hadoop3 checks{color}' > "${OUTPUT_DIR}/commentfile" - status=1 - fi - echo "-- For more information [see jdk11 report|${BUILD_URL}JDK11_20Nightly_20Build_20Report_20_28Hadoop3_29/]" >> "${OUTPUT_DIR}/commentfile" - exit "${status}" ''' + script { + def ret = sh( + returnStatus: true, + script: '''#!/usr/bin/env bash + set -e + declare -i status=0 + if "${BASEDIR}/dev-support/hbase_nightly_yetus.sh" ; then + echo '(/) {color:green}+1 jdk11 hadoop3 checks{color}' > "${OUTPUT_DIR}/commentfile" + else + echo '(x) {color:red}-1 jdk11 hadoop3 checks{color}' > "${OUTPUT_DIR}/commentfile" + status=1 + fi + echo "-- For more information [see jdk11 report|${BUILD_URL}JDK11_20Nightly_20Build_20Report_20_28Hadoop3_29/]" >> "${OUTPUT_DIR}/commentfile" + exit "${status}" + ''' + ) + if (ret != 0) { + // mark the build as UNSTABLE instead of FAILURE, to avoid skipping the later publish of + // test output. See HBASE-26339 for more details. + currentBuild.result = 'UNSTABLE' + } + } } post { always { diff --git a/dev-support/Jenkinsfile_GitHub b/dev-support/Jenkinsfile_GitHub index 56ba85552ed..130a6db155e 100644 --- a/dev-support/Jenkinsfile_GitHub +++ b/dev-support/Jenkinsfile_GitHub @@ -102,12 +102,23 @@ pipeline { passwordVariable: 'GITHUB_PASSWORD', usernameVariable: 'GITHUB_USER' )]) { - sh label: 'test-patch', script: '''#!/bin/bash -e - hostname -a ; pwd ; ls -la - printenv 2>&1 | sort - echo "[INFO] Launching Yetus via ${YETUS_DRIVER}" - "${YETUS_DRIVER}" - ''' + script { + def ret = sh( + label: 'test-patch', + returnStatus: true, + script: '''#!/bin/bash -e + hostname -a ; pwd ; ls -la + printenv 2>&1 | sort + echo "[INFO] Launching Yetus via ${YETUS_DRIVER}" + "${YETUS_DRIVER}" + ''' + ) + if (ret != 0) { + // mark the build as UNSTABLE instead of FAILURE, to avoid skipping the later publish of + // test output. See HBASE-26339 for more details. + currentBuild.result = 'UNSTABLE' + } + } } } } @@ -189,12 +200,23 @@ pipeline { passwordVariable: 'GITHUB_PASSWORD', usernameVariable: 'GITHUB_USER' )]) { - sh label: 'test-patch', script: '''#!/bin/bash -e - hostname -a ; pwd ; ls -la - printenv 2>&1 | sort - echo "[INFO] Launching Yetus via ${YETUS_DRIVER}" - "${YETUS_DRIVER}" - ''' + script { + def ret = sh( + label: 'test-patch', + returnStatus: true, + script: '''#!/bin/bash -e + hostname -a ; pwd ; ls -la + printenv 2>&1 | sort + echo "[INFO] Launching Yetus via ${YETUS_DRIVER}" + "${YETUS_DRIVER}" + ''' + ) + if (ret != 0) { + // mark the build as UNSTABLE instead of FAILURE, to avoid skipping the later publish of + // test output. See HBASE-26339 for more details. + currentBuild.result = 'UNSTABLE' + } + } } } } @@ -309,12 +331,23 @@ pipeline { passwordVariable: 'GITHUB_PASSWORD', usernameVariable: 'GITHUB_USER' )]) { - sh label: 'test-patch', script: '''#!/bin/bash -e - hostname -a ; pwd ; ls -la - printenv 2>&1 | sort - echo "[INFO] Launching Yetus via ${YETUS_DRIVER}" - "${YETUS_DRIVER}" - ''' + script { + def ret = sh( + label: 'test-patch', + returnStatus: true, + script: '''#!/bin/bash -e + hostname -a ; pwd ; ls -la + printenv 2>&1 | sort + echo "[INFO] Launching Yetus via ${YETUS_DRIVER}" + "${YETUS_DRIVER}" + ''' + ) + if (ret != 0) { + // mark the build as UNSTABLE instead of FAILURE, to avoid skipping the later publish of + // test output. See HBASE-26339 for more details. + currentBuild.result = 'UNSTABLE' + } + } } } }