HBASE-18426 nightly job should use independent stages to check supported jdks

* Jenkinsfile that works for all current branches.
* adds dev-support script for setting parameters for our yetus nightly invocation
* quiets the "zip test results" step

Signed-off-by: tedyu <yuzhihong@gmail.com>
This commit is contained in:
Sean Busbey 2017-07-20 01:01:59 -05:00
parent 637f7abf0b
commit 04424ad65f
2 changed files with 241 additions and 103 deletions

View File

@ -20,10 +20,6 @@ pipeline {
label 'Hadoop'
}
}
// work around for YETUS-508, requires maven outside of the dockerfile
tools {
maven 'Maven (latest)'
}
triggers {
cron('@daily')
}
@ -38,8 +34,23 @@ pipeline {
BASEDIR = "${env.WORKSPACE}/component"
YETUS_RELEASE = '0.5.0'
// where we'll write everything from different steps.
OUTPUT_RELATIVE = 'output'
OUTPUTDIR = "${env.WORKSPACE}/output"
OUTPUT_RELATIVE_GENERAL = 'output-general'
OUTPUTDIR_GENERAL = "${env.WORKSPACE}/output-general"
OUTPUT_RELATIVE_JDK7 = 'output-jdk7'
OUTPUTDIR_JDK7 = "${env.WORKSPACE}/output-jdk7"
OUTPUT_RELATIVE_JDK8 = 'output-jdk8'
OUTPUTDIR_JDK8 = "${env.WORKSPACE}/output-jdk8"
PROJECT = 'hbase'
PROJET_PERSONALITY = 'https://raw.githubusercontent.com/apache/hbase/master/dev-support/hbase-personality.sh'
// This section of the docs tells folks not to use the javadoc tag. older branches have our old version of the check for said tag.
AUTHOR_IGNORE_LIST = 'src/main/asciidoc/_chapters/developer.adoc,dev-support/test-patch.sh'
WHITESPACE_IGNORE_LIST = '.*/generated/.*'
// output from surefire; sadly the archive function in yetus only works on file names.
ARCHIVE_PATTERN_LIST = 'TEST-*.xml,org.apache.h*.txt'
// These tests currently have known failures. Once they burn down to 0, remove from here so that new problems will cause a failure.
TESTS_FILTER = 'cc,checkstyle,javac,javadoc,pylint,shellcheck,whitespace,perlcritic,ruby-lint,rubocop'
BRANCH_SPECIFIC_DOCKERFILE = "${env.BASEDIR}/dev-support/docker/Dockerfile"
EXCLUDE_TESTS_URL = 'https://builds.apache.org/job/HBase-Find-Flaky-Tests/lastSuccessfulBuild/artifact/excludes/'
}
parameters {
booleanParam(name: 'USE_YETUS_PRERELEASE', defaultValue: false, description: '''Check to use the current HEAD of apache/yetus rather than our configured release.
@ -48,24 +59,9 @@ pipeline {
booleanParam(name: 'DEBUG', defaultValue: false, description: 'Produce a lot more meta-information.')
}
stages {
stage ('yetus check') {
environment {
PROJECT = 'hbase'
PROJECT_PERSONALITY = 'https://git-wip-us.apache.org/repos/asf?p=hbase.git;a=blob_plain;f=dev-support/hbase-personality.sh;hb=refs/heads/master'
// This section of the docs tells folks not to use the javadoc tag. older branches have our old version of the check for said tag.
AUTHOR_IGNORE_LIST = 'src/main/asciidoc/_chapters/developer.adoc,dev-support/test-patch.sh'
WHITESPACE_IGNORE_LIST = '.*/generated/.*'
// output from surefire; sadly the archive function in yetus only works on file names.
ARCHIVE_PATTERN_LIST = 'TEST-*.xml,org.apache.h*-output.txt,org.apache.h*.txt'
// These tests currently have known failures. Once they burn down to 0, remove from here so that new problems will cause a failure.
TESTS_FILTER = 'cc,checkstyle,javac,javadoc,pylint,shellcheck,whitespace,perlcritic,ruby-lint,rubocop'
BRANCH_SPECIFIC_DOCKERFILE = "${env.BASEDIR}/dev-support/docker/Dockerfile"
EXCLUDE_TESTS_URL = 'https://builds.apache.org/job/HBase-Find-Flaky-Tests/lastSuccessfulBuild/artifact/excludes/'
}
stage ('yetus install') {
steps {
// TODO we can move the yetus install into a different stage and then use stash to deploy it.
sh '''#!/usr/bin/env bash
printenv
echo "Ensure we have a copy of Apache Yetus."
if [[ true != "${USE_YETUS_PRERELEASE}" ]]; then
YETUS_DIR="${WORKSPACE}/yetus-${YETUS_RELEASE}"
@ -101,96 +97,152 @@ if [ ! -d "${YETUS_DIR}" ]; then
gunzip -c yetus.tar.gz | tar xpf - -C "${YETUS_DIR}" --strip-components 1
fi
'''
// TODO we can move the personality install into a different stage and then use stash to deploy it.
dir ("${env.TOOLS}") {
sh """#!/usr/bin/env bash
echo "Downloading Project personality."
curl -L -o personality.sh "${env.PROJECT_PERSONALITY}"
curl -L -o personality.sh "${env.PROJET_PERSONALITY}"
"""
}
// TODO break this out into a script so we can run shellcheck on it.
sh '''#!/usr/bin/env bash
YETUS_ARGS=()
YETUS_ARGS=("--multijdktests=compile,findbugs,unit" "${YETUS_ARGS[@]}")
# On branch-1* this should point to jdk8, since the default JAVA_HOME will be jdk7.
# On branch-2* this should be skipped, since we dropped jdk7 and JAVA_HOME will be jdk8
# On master this should be skipped, since JAVA_HOME will be jdk8
#YETUS_ARGS=("--multijdkdirs=/usr/lib/jvm/java-8-oracle" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--personality=${TOOLS}/personality.sh" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--basedir=${BASEDIR}" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--archive-list=${ARCHIVE_PATTERN_LIST}" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--console-urls" "${YETUS_ARGS[@]}")
# YETUS-532, repeat this twice in case the fix is to update args rather than docs
YETUS_ARGS=("--build-url-patchdir=artifact/${OUTPUT_RELATIVE}" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--build-url-artifacts=artifact/${OUTPUT_RELATIVE}" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--docker" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--dockerfile=${BRANCH_SPECIFIC_DOCKERFILE}" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--empty-patch" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--html-report-file=${OUTPUTDIR}/console-report.html" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--jenkins" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--mvn-custom-repos" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--patch-dir=${OUTPUTDIR}" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--project=${PROJECT}" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--resetrepo" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--author-ignore-list=${AUTHOR_IGNORE_LIST}" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--whitespace-eol-ignore-list=${WHITESPACE_IGNORE_LIST}" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--whitespace-tabs-ignore-list=${WHITESPACE_IGNORE_LIST}" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--sentinel" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--branch=${BRANCH_NAME}" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--tests-filter=${TESTS_FILTER}" "${YETUS_ARGS[@]}")
if [[ true == "${DEBUG}" ]]; then
YETUS_ARGS=("--debug" "${YETUS_ARGS[@]}")
fi
rm -rf "${OUTPUTDIR}"
mkdir -p "${OUTPUTDIR}"
if [[ true != "${USE_YETUS_PRERELEASE}" ]]; then
YETUS_ARGS=("--shelldocs=${WORKSPACE}/yetus-${YETUS_RELEASE}/bin/shelldocs" "${YETUS_ARGS[@]}")
TESTPATCHBIN="${WORKSPACE}/yetus-${YETUS_RELEASE}/bin/test-patch"
else
YETUS_ARGS=("--shelldocs=${WORKSPACE}/yetus-git/shelldocs/shelldocs.py" "${YETUS_ARGS[@]}")
TESTPATCHBIN="${WORKSPACE}/yetus-git/precommit/test-patch.sh"
fi
echo "Launching yetus with command line:"
echo "${TESTPATCHBIN} ${YETUS_ARGS[*]}"
/usr/bin/env bash "${TESTPATCHBIN}" "${YETUS_ARGS[@]}"
'''
stash name: 'yetus', includes: "yetus-*/*,yetus-*/**/*,tools/personality.sh"
}
}
stage ('yetus general check') {
environment {
// TODO does hadoopcheck need to be jdk specific?
// Should be things that work with multijdk
TESTS = 'all,-unit,-findbugs'
// on branches that don't support jdk7, this will already be JAVA_HOME, so we'll end up not
// doing multijdk there.
MULTIJDK = '/usr/lib/jvm/java-8-oracle'
OUTPUT_RELATIVE = "${env.OUTPUT_RELATIVE_GENERAL}"
OUTPUTDIR = "${env.OUTPUTDIR_GENERAL}"
}
steps {
unstash 'yetus'
// TODO should this be a download from master, similar to how the personality is?
sh "${env.BASEDIR}/dev-support/hbase_nightly_yetus.sh"
}
post {
always {
// env variables don't work in archive? or this has to be relative to WORKSPACE. :(
archive 'output-general/*'
archive 'output-general/**/*'
publishHTML target: [
allowMissing: true,
keepAll: true,
alwaysLinkToLastBuild: true,
// has to be relative to WORKSPACE :(
reportDir: 'output-general',
reportFiles: 'console-report.html',
reportName: 'General Nightly Build Report'
]
}
}
}
stage ('yetus jdk7 checks') {
when {
branch 'branch-1*'
}
environment {
TESTS = 'mvninstall,compile,javac,unit,htmlout'
OUTPUT_RELATIVE = "${env.OUTPUT_RELATIVE_JDK7}"
OUTPUTDIR = "${env.OUTPUTDIR_JDK7}"
// On branches where we do jdk7 checks, jdk7 will be JAVA_HOME already.
}
steps {
unstash 'yetus'
sh """#!/usr/bin/env bash
# for branch-1.1 we don't do jdk8 findbugs, so do it here
if [ "${env.BRANCH_NAME}" == "branch-1.1" ]; then
TESTS+=",findbugs"
fi
"${env.BASEDIR}/dev-support/hbase_nightly_yetus.sh"
"""
}
post {
always {
junit 'output-jdk7/**/target/**/TEST-*.xml'
// zip surefire reports.
sh '''#!/bin/bash -e
if [ -d "${OUTPUTDIR}/archiver" ]; then
count=$(find "${OUTPUTDIR}/archiver" -type f | wc -l)
if [[ 0 -ne ${count} ]]; then
echo "zipping ${count} archived files"
zip -q -m -r "${OUTPUTDIR}/test_logs.zip" "${OUTPUTDIR}/archiver"
else
echo "No archived files, skipping compressing."
fi
else
echo "No archiver directory, skipping compressing."
fi
'''
// env variables don't work in archive? or this has to be relative to WORKSPACE. :(
archive 'output-jdk7/*'
archive 'output-jdk7/**/*'
publishHTML target: [
allowMissing: true,
keepAll: true,
alwaysLinkToLastBuild: true,
// has to be relative to WORKSPACE :(
reportDir: 'output-jdk7',
reportFiles: 'console-report.html',
reportName: 'JDK7 Nightly Build Report'
]
}
}
}
stage ('yetus jdk8 checks') {
when {
not {
branch 'branch-1.1*'
}
}
environment {
TESTS = 'mvninstall,compile,javac,unit,findbugs,htmlout'
OUTPUT_RELATIVE = "${env.OUTPUT_RELATIVE_JDK8}"
OUTPUTDIR = "${env.OUTPUTDIR_JDK8}"
// This isn't strictly needed on branches that only support jdk8, but doesn't hurt
// and is needed on branches that do both jdk7 and jdk8
SET_JAVA_HOME = '/usr/lib/jvm/java-8-oracle'
}
steps {
unstash 'yetus'
sh "${env.BASEDIR}/dev-support/hbase_nightly_yetus.sh"
}
post {
always {
junit 'output-jdk8/**/target/**/TEST-*.xml'
// zip surefire reports.
sh '''#!/bin/bash -e
if [ -d "${OUTPUTDIR}/archiver" ]; then
count=$(find "${OUTPUTDIR}/archiver" -type f | wc -l)
if [[ 0 -ne ${count} ]]; then
echo "zipping ${count} archived files"
zip -q -m -r "${OUTPUTDIR}/test_logs.zip" "${OUTPUTDIR}/archiver"
else
echo "No archived files, skipping compressing."
fi
else
echo "No archiver directory, skipping compressing."
fi
'''
// env variables don't work in archive? or this has to be relative to WORKSPACE. :(
archive 'output-jdk8/*'
archive 'output-jdk8/**/*'
publishHTML target: [
allowMissing: true,
keepAll: true,
alwaysLinkToLastBuild: true,
// has to be relative to WORKSPACE :(
reportDir: 'output-jdk8',
reportFiles: 'console-report.html',
reportName: 'JDK8 Nightly Build Report'
]
}
}
}
}
post {
always {
// TODO confirm junit step accounts for multijdk results
junit 'output/**/target/**/TEST-*.xml'
// gzip surefire reports.
sh '''#!/bin/bash -e
if [ -d "${OUTPUTDIR}/archiver" ]; then
count=$(find "${OUTPUTDIR}/archiver" -type f | wc -l)
if [[ 0 -ne ${count} ]]; then
echo "zipping ${count} archived files"
zip -m -r "${OUTPUTDIR}/test_logs.zip" "${OUTPUTDIR}/archiver"
else
echo "No archived files, skipping compressing."
fi
else
echo "No archiver directory, skipping compressing."
fi
'''
// env variables don't work in archive? or this has to be relative to WORKSPACE. :(
archive 'output/*'
archive 'output/**/*'
publishHTML target: [
allowMissing: true,
keepAll: true,
alwaysLinkToLastBuild: true,
// has to be relative to WORKSPACE :(
reportDir: 'output',
reportFiles: 'console-report.html',
reportName: 'Nightly Build Report'
]
}
failure {
deleteDir()
}

View File

@ -0,0 +1,86 @@
#!/usr/bin/env bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
declare -i missing_env=0
# Validate params
for required_env in "TESTS" "TOOLS" "BASEDIR" "ARCHIVE_PATTERN_LIST" "OUTPUT_RELATIVE" \
"BRANCH_SPECIFIC_DOCKERFILE" "OUTPUTDIR" "PROJECT" "AUTHOR_IGNORE_LIST" \
"WHITESPACE_IGNORE_LIST" "BRANCH_NAME" "TESTS_FILTER" "DEBUG" \
"USE_YETUS_PRERELEASE" "WORKSPACE" "YETUS_RELEASE"; do
if [ -z "${!required_env}" ]; then
echo "[ERROR] Required environment variable '${required_env}' is not set."
missing_env=${missing_env}+1
fi
done
if [ ${missing_env} -gt 0 ]; then
echo "[ERROR] Please set the required environment variables before invoking. If this error is " \
"on Jenkins, then please file a JIRA about the error."
exit 1
fi
YETUS_ARGS=()
if [[ -n "${MULTIJDK}" ]]; then
YETUS_ARGS=("--multijdktests=compile,javadoc" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--multijdkdirs=${MULTIJDK}" "${YETUS_ARGS[@]}")
fi
if [[ -n "${SET_JAVA_HOME}" ]]; then
YETUS_ARGS=("--java-home=${SET_JAVA_HOME}" "${YETUS_ARGS[@]}")
fi
YETUS_ARGS=("--plugins=${TESTS}" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--personality=${TOOLS}/personality.sh" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--basedir=${BASEDIR}" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--archive-list=${ARCHIVE_PATTERN_LIST}" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--console-urls" "${YETUS_ARGS[@]}")
# YETUS-532, repeat this twice in case the fix is to update args rather than docs
YETUS_ARGS=("--build-url-patchdir=artifact/${OUTPUT_RELATIVE}" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--build-url-artifacts=artifact/${OUTPUT_RELATIVE}" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--docker" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--dockerfile=${BRANCH_SPECIFIC_DOCKERFILE}" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--empty-patch" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--html-report-file=${OUTPUTDIR}/console-report.html" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--jenkins" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--mvn-custom-repos" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--patch-dir=${OUTPUTDIR}" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--project=${PROJECT}" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--resetrepo" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--author-ignore-list=${AUTHOR_IGNORE_LIST}" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--whitespace-eol-ignore-list=${WHITESPACE_IGNORE_LIST}" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--whitespace-tabs-ignore-list=${WHITESPACE_IGNORE_LIST}" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--sentinel" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--branch=${BRANCH_NAME}" "${YETUS_ARGS[@]}")
YETUS_ARGS=("--tests-filter=${TESTS_FILTER}" "${YETUS_ARGS[@]}")
if [[ true == "${DEBUG}" ]]; then
YETUS_ARGS=("--debug" "${YETUS_ARGS[@]}")
fi
rm -rf "${OUTPUTDIR}"
mkdir -p "${OUTPUTDIR}"
if [[ true != "${USE_YETUS_PRERELEASE}" ]]; then
YETUS_ARGS=("--shelldocs=${WORKSPACE}/yetus-${YETUS_RELEASE}/bin/shelldocs" "${YETUS_ARGS[@]}")
TESTPATCHBIN="${WORKSPACE}/yetus-${YETUS_RELEASE}/bin/test-patch"
else
YETUS_ARGS=("--shelldocs=${WORKSPACE}/yetus-git/shelldocs/shelldocs.py" "${YETUS_ARGS[@]}")
TESTPATCHBIN="${WORKSPACE}/yetus-git/precommit/test-patch.sh"
fi
echo "Launching yetus with command line:"
echo "${TESTPATCHBIN} ${YETUS_ARGS[*]}"
/usr/bin/env bash "${TESTPATCHBIN}" "${YETUS_ARGS[@]}"