2019-01-05 15:14:50 -05:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
pipeline {
|
|
|
|
|
|
|
|
agent {
|
|
|
|
label 'Hadoop'
|
|
|
|
}
|
|
|
|
|
|
|
|
options {
|
|
|
|
buildDiscarder(logRotator(numToKeepStr: '5'))
|
2020-07-01 03:52:25 -04:00
|
|
|
timeout (time: 20, unit: 'HOURS')
|
2019-01-05 15:14:50 -05:00
|
|
|
timestamps()
|
|
|
|
checkoutToSubdirectory('src')
|
|
|
|
}
|
|
|
|
|
|
|
|
environment {
|
|
|
|
SOURCEDIR = 'src'
|
|
|
|
// will also need to change notification section below
|
|
|
|
PATCHDIR = 'out'
|
|
|
|
DOCKERFILE = "${SOURCEDIR}/dev-support/docker/Dockerfile"
|
|
|
|
YETUS='yetus'
|
|
|
|
// Branch or tag name. Yetus release tags are 'rel/X.Y.Z'
|
2021-03-11 07:48:47 -05:00
|
|
|
YETUS_VERSION='11eb9b09786e401fbdeaa3be83a19a4066fd7813'
|
2019-01-05 15:14:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
parameters {
|
|
|
|
string(name: 'JIRA_ISSUE_KEY',
|
|
|
|
defaultValue: '',
|
|
|
|
description: 'The JIRA issue that has a patch needing pre-commit testing. Example: HADOOP-1234')
|
|
|
|
}
|
|
|
|
|
|
|
|
stages {
|
|
|
|
stage ('install yetus') {
|
|
|
|
steps {
|
|
|
|
dir("${WORKSPACE}/${YETUS}") {
|
|
|
|
checkout([
|
|
|
|
$class: 'GitSCM',
|
|
|
|
branches: [[name: "${env.YETUS_VERSION}"]],
|
|
|
|
userRemoteConfigs: [[ url: 'https://github.com/apache/yetus.git']]]
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage ('precommit-run') {
|
|
|
|
steps {
|
|
|
|
withCredentials(
|
2021-02-20 03:18:23 -05:00
|
|
|
[usernamePassword(credentialsId: '683f5dcf-5552-4b28-9fb1-6a6b77cf53dd',
|
2020-04-18 13:43:44 -04:00
|
|
|
passwordVariable: 'GITHUB_TOKEN',
|
2019-01-05 15:14:50 -05:00
|
|
|
usernameVariable: 'GITHUB_USER'),
|
|
|
|
usernamePassword(credentialsId: 'hadoopqa-at-asf-jira',
|
|
|
|
passwordVariable: 'JIRA_PASSWORD',
|
|
|
|
usernameVariable: 'JIRA_USER')]) {
|
|
|
|
sh '''#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
TESTPATCHBIN="${WORKSPACE}/${YETUS}/precommit/src/main/shell/test-patch.sh"
|
|
|
|
|
|
|
|
# this must be clean for every run
|
|
|
|
if [[ -d "${WORKSPACE}/${PATCHDIR}" ]]; then
|
|
|
|
rm -rf "${WORKSPACE}/${PATCHDIR}"
|
|
|
|
fi
|
|
|
|
mkdir -p "${WORKSPACE}/${PATCHDIR}"
|
|
|
|
|
|
|
|
# if given a JIRA issue, process it. If CHANGE_URL is set
|
|
|
|
# (e.g., Github Branch Source plugin), process it.
|
|
|
|
# otherwise exit, because we don't want Hadoop to do a
|
|
|
|
# full build. We wouldn't normally do this check for smaller
|
|
|
|
# projects. :)
|
|
|
|
if [[ -n "${JIRA_ISSUE_KEY}" ]]; then
|
|
|
|
YETUS_ARGS+=("${JIRA_ISSUE_KEY}")
|
|
|
|
elif [[ -z "${CHANGE_URL}" ]]; then
|
|
|
|
echo "Full build skipped" > "${WORKSPACE}/${PATCHDIR}/report.html"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
YETUS_ARGS+=("--patch-dir=${WORKSPACE}/${PATCHDIR}")
|
|
|
|
|
|
|
|
# where the source is located
|
|
|
|
YETUS_ARGS+=("--basedir=${WORKSPACE}/${SOURCEDIR}")
|
|
|
|
|
|
|
|
# our project defaults come from a personality file
|
|
|
|
YETUS_ARGS+=("--project=hadoop")
|
2020-08-17 23:08:58 -04:00
|
|
|
YETUS_ARGS+=("--personality=${WORKSPACE}/${SOURCEDIR}/dev-support/bin/hadoop.sh")
|
2019-01-05 15:14:50 -05:00
|
|
|
|
|
|
|
# lots of different output formats
|
|
|
|
YETUS_ARGS+=("--brief-report-file=${WORKSPACE}/${PATCHDIR}/brief.txt")
|
|
|
|
YETUS_ARGS+=("--console-report-file=${WORKSPACE}/${PATCHDIR}/console.txt")
|
|
|
|
YETUS_ARGS+=("--html-report-file=${WORKSPACE}/${PATCHDIR}/report.html")
|
|
|
|
|
|
|
|
# enable writing back to Github
|
2020-04-18 13:43:44 -04:00
|
|
|
YETUS_ARGS+=(--github-token="${GITHUB_TOKEN}")
|
2019-01-05 15:14:50 -05:00
|
|
|
|
|
|
|
# enable writing back to ASF JIRA
|
|
|
|
YETUS_ARGS+=(--jira-password="${JIRA_PASSWORD}")
|
|
|
|
YETUS_ARGS+=(--jira-user="${JIRA_USER}")
|
|
|
|
|
|
|
|
# auto-kill any surefire stragglers during unit test runs
|
|
|
|
YETUS_ARGS+=("--reapermode=kill")
|
|
|
|
|
|
|
|
# set relatively high limits for ASF machines
|
|
|
|
# changing these to higher values may cause problems
|
|
|
|
# with other jobs on systemd-enabled machines
|
|
|
|
YETUS_ARGS+=("--proclimit=5500")
|
2021-01-12 01:34:06 -05:00
|
|
|
YETUS_ARGS+=("--dockermemlimit=22g")
|
2019-01-05 15:14:50 -05:00
|
|
|
|
2021-03-10 20:56:07 -05:00
|
|
|
# -1 spotbugs issues that show up prior to the patch being applied
|
|
|
|
YETUS_ARGS+=("--spotbugs-strict-precheck")
|
2019-01-05 15:14:50 -05:00
|
|
|
|
|
|
|
# rsync these files back into the archive dir
|
2021-03-10 20:56:07 -05:00
|
|
|
YETUS_ARGS+=("--archive-list=checkstyle-errors.xml,spotbugsXml.xml")
|
2019-01-05 15:14:50 -05:00
|
|
|
|
|
|
|
# URL for user-side presentation in reports and such to our artifacts
|
|
|
|
# (needs to match the archive bits below)
|
|
|
|
YETUS_ARGS+=("--build-url-artifacts=artifact/out")
|
|
|
|
|
|
|
|
# plugins to enable
|
|
|
|
YETUS_ARGS+=("--plugins=all")
|
|
|
|
|
|
|
|
# don't let these tests cause -1s because we aren't really paying that
|
|
|
|
# much attention to them
|
|
|
|
YETUS_ARGS+=("--tests-filter=checkstyle")
|
|
|
|
|
|
|
|
# run in docker mode and specifically point to our
|
|
|
|
# Dockerfile since we don't want to use the auto-pulled version.
|
|
|
|
YETUS_ARGS+=("--docker")
|
|
|
|
YETUS_ARGS+=("--dockerfile=${DOCKERFILE}")
|
2020-08-04 21:39:56 -04:00
|
|
|
YETUS_ARGS+=("--mvn-custom-repos")
|
2019-01-05 15:14:50 -05:00
|
|
|
|
|
|
|
# effectively treat dev-suport as a custom maven module
|
2019-11-19 03:51:49 -05:00
|
|
|
YETUS_ARGS+=("--skip-dirs=dev-support")
|
2019-01-05 15:14:50 -05:00
|
|
|
|
|
|
|
# help keep the ASF boxes clean
|
|
|
|
YETUS_ARGS+=("--sentinel")
|
|
|
|
|
2020-06-19 00:29:44 -04:00
|
|
|
# test with Java 8 and 11
|
|
|
|
YETUS_ARGS+=("--java-home=/usr/lib/jvm/java-8-openjdk-amd64")
|
|
|
|
YETUS_ARGS+=("--multijdkdirs=/usr/lib/jvm/java-11-openjdk-amd64")
|
|
|
|
YETUS_ARGS+=("--multijdktests=compile")
|
|
|
|
|
2020-08-02 21:46:51 -04:00
|
|
|
# custom javadoc goals
|
|
|
|
YETUS_ARGS+=("--mvn-javadoc-goals=process-sources,javadoc:javadoc-no-fork")
|
|
|
|
|
2021-03-11 07:48:47 -05:00
|
|
|
# write Yetus report as GitHub comment (YETUS-1102)
|
|
|
|
YETUS_ARGS+=("--github-write-comment")
|
|
|
|
YETUS_ARGS+=("--github-use-emoji-vote")
|
|
|
|
|
2019-01-05 15:14:50 -05:00
|
|
|
"${TESTPATCHBIN}" "${YETUS_ARGS[@]}"
|
|
|
|
'''
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
post {
|
|
|
|
always {
|
|
|
|
script {
|
2021-02-20 03:18:23 -05:00
|
|
|
// Publish status if it was missed (YETUS-1059)
|
|
|
|
withCredentials(
|
|
|
|
[usernamePassword(credentialsId: '683f5dcf-5552-4b28-9fb1-6a6b77cf53dd',
|
|
|
|
passwordVariable: 'GITHUB_TOKEN',
|
|
|
|
usernameVariable: 'GITHUB_USER')]) {
|
|
|
|
sh '''#!/usr/bin/env bash
|
|
|
|
YETUS_ARGS+=("--github-token=${GITHUB_TOKEN}")
|
|
|
|
YETUS_ARGS+=("--patch-dir=${WORKSPACE}/${PATCHDIR}")
|
|
|
|
TESTPATCHBIN="${WORKSPACE}/${YETUS}/precommit/src/main/shell/github-status-recovery.sh"
|
|
|
|
/usr/bin/env bash "${TESTPATCHBIN}" "${YETUS_ARGS[@]}" ${EXTRA_ARGS} || true
|
|
|
|
'''
|
|
|
|
}
|
|
|
|
|
2019-01-05 15:14:50 -05:00
|
|
|
// Yetus output
|
|
|
|
archiveArtifacts "${env.PATCHDIR}/**"
|
|
|
|
// Publish the HTML report so that it can be looked at
|
|
|
|
// Has to be relative to WORKSPACE.
|
|
|
|
publishHTML (target: [
|
|
|
|
allowMissing: true,
|
|
|
|
keepAll: true,
|
|
|
|
alwaysLinkToLastBuild: true,
|
|
|
|
// Has to be relative to WORKSPACE
|
|
|
|
reportDir: "${env.PATCHDIR}",
|
|
|
|
reportFiles: 'report.html',
|
|
|
|
reportName: 'Yetus Report'
|
|
|
|
])
|
|
|
|
// Publish JUnit results
|
|
|
|
try {
|
|
|
|
junit "${env.SOURCEDIR}/**/target/surefire-reports/*.xml"
|
|
|
|
} catch(e) {
|
|
|
|
echo 'junit processing: ' + e.toString()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Jenkins pipeline jobs fill slaves on PRs without this :(
|
|
|
|
cleanup() {
|
|
|
|
script {
|
|
|
|
sh '''
|
|
|
|
# See YETUS-764
|
|
|
|
if [ -f "${WORKSPACE}/${PATCHDIR}/pidfile.txt" ]; then
|
|
|
|
echo "test-patch process appears to still be running: killing"
|
|
|
|
kill `cat "${WORKSPACE}/${PATCHDIR}/pidfile.txt"` || true
|
|
|
|
sleep 10
|
|
|
|
fi
|
|
|
|
if [ -f "${WORKSPACE}/${PATCHDIR}/cidfile.txt" ]; then
|
|
|
|
echo "test-patch container appears to still be running: killing"
|
|
|
|
docker kill `cat "${WORKSPACE}/${PATCHDIR}/cidfile.txt"` || true
|
|
|
|
fi
|
|
|
|
# See HADOOP-13951
|
|
|
|
chmod -R u+rxw "${WORKSPACE}"
|
|
|
|
'''
|
|
|
|
deleteDir()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-05-02 10:48:30 -04:00
|
|
|
}
|