HBASE-20335 nightly job bash cleanup.

* Ensure Jenkins steps that invoke bash inline set -e
* machine stats script should check that passed directory will work

Signed-off-by: Michael Stack <st...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/a2c1be9a
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/a2c1be9a
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/a2c1be9a

Branch: refs/heads/HBASE-19064
Commit: a2c1be9a7674e5d18892b72b2984a524c7dc64c9
Parents: 83ee82d
Author: Sean Busbey <bus...@apache.org>
Authored: Tue Apr 3 12:08:05 2018 -0500
Committer: Sean Busbey <bus...@apache.org>
Committed: Wed Apr 11 01:33:14 2018 -0500

----------------------------------------------------------------------
 dev-support/Jenkinsfile                   | 11 +++++++++++
 dev-support/gather_machine_environment.sh |  5 +++++
 2 files changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/a2c1be9a/dev-support/Jenkinsfile
----------------------------------------------------------------------
diff --git a/dev-support/Jenkinsfile b/dev-support/Jenkinsfile
index e8bf8c9..3f3066b 100644
--- a/dev-support/Jenkinsfile
+++ b/dev-support/Jenkinsfile
@@ -63,6 +63,7 @@ pipeline {
     stage ('yetus install') {
       steps {
         sh  '''#!/usr/bin/env bash
+set -e
 echo "Ensure we have a copy of Apache Yetus."
 if [[ true !=  "${USE_YETUS_PRERELEASE}" ]]; then
   YETUS_DIR="${WORKSPACE}/yetus-${YETUS_RELEASE}"
@@ -101,6 +102,7 @@ fi
         // Set up the file we need at PERSONALITY_FILE location
         dir ("tools") {
           sh """#!/usr/bin/env bash
+set -e
 echo "Downloading Project personality."
 curl -L  -o personality.sh "${env.PROJECT_PERSONALITY}"
           """
@@ -144,12 +146,14 @@ curl -L  -o personality.sh "${env.PROJECT_PERSONALITY}"
               checkout scm
             }
             sh '''#!/usr/bin/env bash
+              set -e
               rm -rf "${OUTPUT_DIR}" && mkdir "${OUTPUT_DIR}"
               rm -rf "${OUTPUT_DIR}/machine" && mkdir "${OUTPUT_DIR}/machine"
               "${BASEDIR}/dev-support/gather_machine_environment.sh" 
"${OUTPUT_DIR_RELATIVE}/machine"
 '''
             // TODO roll this into the hbase_nightly_yetus script
             sh '''#!/usr/bin/env bash
+              set -e
               rm -rf "${OUTPUT_DIR}/commentfile}"
               declare -i status=0
               if "${BASEDIR}/dev-support/hbase_nightly_yetus.sh" ; then
@@ -202,11 +206,13 @@ curl -L  -o personality.sh "${env.PROJECT_PERSONALITY}"
               checkout scm
             }
             sh '''#!/usr/bin/env bash
+              set -e
               rm -rf "${OUTPUT_DIR}" && mkdir "${OUTPUT_DIR}"
               rm -rf "${OUTPUT_DIR}/machine" && mkdir "${OUTPUT_DIR}/machine"
               "${BASEDIR}/dev-support/gather_machine_environment.sh" 
"${OUTPUT_DIR_RELATIVE}/machine"
 '''
             sh '''#!/usr/bin/env bash
+              set -e
               rm -rf "${OUTPUT_DIR}/commentfile}"
               declare -i status=0
               if "${BASEDIR}/dev-support/hbase_nightly_yetus.sh" ; then
@@ -273,11 +279,13 @@ curl -L  -o personality.sh "${env.PROJECT_PERSONALITY}"
               checkout scm
             }
             sh '''#!/usr/bin/env bash
+              set -e
               rm -rf "${OUTPUT_DIR}" && mkdir "${OUTPUT_DIR}"
               rm -rf "${OUTPUT_DIR}/machine" && mkdir "${OUTPUT_DIR}/machine"
               "${BASEDIR}/dev-support/gather_machine_environment.sh" 
"${OUTPUT_DIR_RELATIVE}/machine"
 '''
             sh '''#!/usr/bin/env bash
+              set -e
               rm -rf "${OUTPUT_DIR}/commentfile}"
               declare -i status=0
               if "${BASEDIR}/dev-support/hbase_nightly_yetus.sh" ; then
@@ -351,11 +359,13 @@ curl -L  -o personality.sh "${env.PROJECT_PERSONALITY}"
               checkout scm
             }
             sh '''#!/usr/bin/env bash
+              set -e
               rm -rf "${OUTPUT_DIR}" && mkdir "${OUTPUT_DIR}"
               rm -rf "${OUTPUT_DIR}/machine" && mkdir "${OUTPUT_DIR}/machine"
               "${BASEDIR}/dev-support/gather_machine_environment.sh" 
"${OUTPUT_DIR_RELATIVE}/machine"
 '''
             sh '''#!/usr/bin/env bash
+              set -e
               rm -rf "${OUTPUT_DIR}/commentfile}"
               declare -i status=0
               if "${BASEDIR}/dev-support/hbase_nightly_yetus.sh" ; then
@@ -425,6 +435,7 @@ curl -L  -o personality.sh "${env.PROJECT_PERSONALITY}"
               checkout scm
             }
             sh '''#!/usr/bin/env bash
+              set -e
               rm -rf "output-srctarball/machine" && mkdir 
"output-srctarball/machine"
               "${BASEDIR}/dev-support/gather_machine_environment.sh" 
"output-srctarball/machine"
 '''

http://git-wip-us.apache.org/repos/asf/hbase/blob/a2c1be9a/dev-support/gather_machine_environment.sh
----------------------------------------------------------------------
diff --git a/dev-support/gather_machine_environment.sh 
b/dev-support/gather_machine_environment.sh
index 589dffe..fa99d3f 100755
--- a/dev-support/gather_machine_environment.sh
+++ b/dev-support/gather_machine_environment.sh
@@ -33,6 +33,11 @@ fi
 
 declare output=$1
 
+if [ ! -d "${output}" ] || [ ! -w "${output}" ]; then
+  echo "Specified output directory must exist and be writable." >&2
+  exit 1
+fi
+
 echo "getting machine specs, find in ${BUILD_URL}/artifact/${output}/"
 echo "JAVA_HOME: ${JAVA_HOME}" >"${output}/java_home" 2>&1 || true
 ls -l "${JAVA_HOME}" >"${output}/java_home_ls" 2>&1 || true

Reply via email to