From 07fafc9b396daf484bff5252b0cdbac43732bc7d Mon Sep 17 00:00:00 2001 From: Misty Stanley-Jones Date: Mon, 26 Feb 2018 11:08:31 -0800 Subject: [PATCH] HBASE-20070 fix website build script Use more stable commands to get the current hash and test whether we already published it Improve logic of script to bail out earlier in case of problems Signed-off-by: Misty Stanley-Jones --- .../jenkins-scripts/generate-hbase-website.sh | 27 +++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/dev-support/jenkins-scripts/generate-hbase-website.sh b/dev-support/jenkins-scripts/generate-hbase-website.sh index 06d160a64c..38b347d257 100644 --- a/dev-support/jenkins-scripts/generate-hbase-website.sh +++ b/dev-support/jenkins-scripts/generate-hbase-website.sh @@ -43,9 +43,23 @@ export MAVEN_OPTS="-XX:MaxPermSize=256m -Dmaven.repo.local=${LOCAL_REPO}" # Verify the Maven version mvn -version +# Jenkins clones the hbase repo into subdir hbase. Go there. +if [ -d hbase ]; then + cd hbase +else + echo "Can't find the hbase subdirectory. Bailing." + exit 1 +fi + # Save and print the SHA we are building -CURRENT_HBASE_COMMIT="$(git log --pretty=format:%H -n1)" -echo "Current HBase commit: $CURRENT_HBASE_COMMIT" +CURRENT_HBASE_COMMIT="$(git rev-parse HEAD)" +if [ -z "$CURRENT_HBASE_COMMIT "]; then + echo "Couldn't determine the currenrt commit. Bailing out." + exit 1 +else + echo "Current HBase commit: $CURRENT_HBASE_COMMIT" +fi +cd ${WORKSPACE} # Clone the hbase-site repo manually so it doesn't trigger spurious # commits in Jenkins. @@ -54,15 +68,12 @@ git clone --depth 1 --branch asf-site https://git-wip-us.apache.org/repos/asf/hb # Figure out the last commit we built the site from, and bail if the build # still represents the SHA of HBase master cd "${WORKSPACE}/hbase-site" || exit -1 -git log --pretty=%s | grep ${CURRENT_HBASE_COMMIT} -PUSHED=$? -echo "PUSHED is $PUSHED" - -if [ $PUSHED -eq 0 ]; then +PUSHED=$(git log -pretty=%H | grep ${CURRENT_HBASE_COMMIT}) +if [ -s "$PUSHED" ]; then echo "$CURRENT_HBASE_COMMIT is already mentioned in the hbase-site commit log. Not building." exit 0 else - echo "$CURRENT_HBASE_COMMIT is not yet mentioned in the hbase-site commit log. Assuming we don't have it yet. $PUSHED" + echo "$CURRENT_HBASE_COMMIT is not yet mentioned in the hbase-site commit log. Assuming we don't have it yet and continuing to build." fi # Go to the hbase directory so we can build the site -- 2.14.1