|
| 1 | +// Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The ASF licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// with the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +pipeline { |
| 19 | + |
| 20 | + agent { |
| 21 | + label 'Hadoop || ubuntu' |
| 22 | + } |
| 23 | + |
| 24 | + options { |
| 25 | + buildDiscarder(logRotator(numToKeepStr: '30')) |
| 26 | + timeout (time: 7, unit: 'HOURS') |
| 27 | + timestamps() |
| 28 | + checkoutToSubdirectory('src') |
| 29 | + } |
| 30 | + |
| 31 | + environment { |
| 32 | + SOURCEDIR = 'src' |
| 33 | + // will also need to change notification section below |
| 34 | + PATCHDIR = 'out' |
| 35 | + DOCKERFILE = "${SOURCEDIR}/dev-support/docker/Dockerfile" |
| 36 | + YETUS='yetus' |
| 37 | + // Branch or tag name. Yetus release tags are 'rel/X.Y.Z' |
| 38 | + YETUS_VERSION='rel/0.9.0' |
| 39 | + } |
| 40 | + |
| 41 | + parameters { |
| 42 | + string(name: 'JIRA_ISSUE_KEY', |
| 43 | + defaultValue: '', |
| 44 | + description: 'The JIRA issue that has a patch needing pre-commit testing. Example: HBASE-1234') |
| 45 | + } |
| 46 | + |
| 47 | + stages { |
| 48 | + stage ('install yetus') { |
| 49 | + steps { |
| 50 | + dir("${WORKSPACE}/${YETUS}") { |
| 51 | + checkout([ |
| 52 | + $class: 'GitSCM', |
| 53 | + branches: [[name: "${env.YETUS_VERSION}"]], |
| 54 | + userRemoteConfigs: [[ url: 'https://github.com/apache/yetus.git']]] |
| 55 | + ) |
| 56 | + } |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + stage ('precommit-run') { |
| 61 | + steps { |
| 62 | + withCredentials( |
| 63 | + [usernamePassword(credentialsId: 'apache-hadoop-at-github.com', |
| 64 | + passwordVariable: 'GITHUB_PASSWORD', |
| 65 | + usernameVariable: 'GITHUB_USER'), |
| 66 | + usernamePassword(credentialsId: 'hadoopqa-at-asf-jira', |
| 67 | + passwordVariable: 'JIRA_PASSWORD', |
| 68 | + usernameVariable: 'JIRA_USER')]) { |
| 69 | + sh '''#!/usr/bin/env bash |
| 70 | + set -e |
| 71 | + TESTPATCHBIN="${WORKSPACE}/${YETUS}/precommit/src/main/shell/test-patch.sh" |
| 72 | + # this must be clean for every run |
| 73 | + if [[ -d "${WORKSPACE}/${PATCHDIR}" ]]; then |
| 74 | + rm -rf "${WORKSPACE}/${PATCHDIR}" |
| 75 | + fi |
| 76 | + mkdir -p "${WORKSPACE}/${PATCHDIR}" |
| 77 | + |
| 78 | + ## Checking on H* machine nonsense |
| 79 | + echo "JAVA_HOME: ${JAVA_HOME}" |
| 80 | + ls -l "${JAVA_HOME}" || true |
| 81 | + echo "MAVEN_HOME: ${MAVEN_HOME}" |
| 82 | + echo "maven version:" |
| 83 | + mvn --offline --version || true |
| 84 | + echo "getting machine specs, find in ${BUILD_URL}/artifact/patchprocess/machine/" |
| 85 | + mkdir "${PATCHDIR}/machine" |
| 86 | + cat /proc/cpuinfo >"${PATCHDIR}/machine/cpuinfo" 2>&1 || true |
| 87 | + cat /proc/meminfo >"${PATCHDIR}/machine/meminfo" 2>&1 || true |
| 88 | + cat /proc/diskstats >"${PATCHDIR}/machine/diskstats" 2>&1 || true |
| 89 | + cat /sys/block/sda/stat >"${PATCHDIR}/machine/sys-block-sda-stat" 2>&1 || true |
| 90 | + df -h >"${PATCHDIR}/machine/df-h" 2>&1 || true |
| 91 | + ps -Awwf >"${PATCHDIR}/machine/ps-Awwf" 2>&1 || true |
| 92 | + ifconfig -a >"${PATCHDIR}/machine/ifconfig-a" 2>&1 || true |
| 93 | + lsblk -ta >"${PATCHDIR}/machine/lsblk-ta" 2>&1 || true |
| 94 | + lsblk -fa >"${PATCHDIR}/machine/lsblk-fa" 2>&1 || true |
| 95 | + cat /proc/loadavg >"${output}/loadavg" 2>&1 || true |
| 96 | + ulimit -a >"${PATCHDIR}/machine/ulimit-a" 2>&1 || true |
| 97 | + ## /H* |
| 98 | + |
| 99 | + # if given a JIRA issue, process it. If CHANGE_URL is set |
| 100 | + # (e.g., Github Branch Source plugin), process it. |
| 101 | + # otherwise exit, because we don't want HBase to do a |
| 102 | + # full build. We wouldn't normally do this check for smaller |
| 103 | + # projects. :) |
| 104 | + if [[ -n "${JIRA_ISSUE_KEY}" ]]; then |
| 105 | + YETUS_ARGS+=("${JIRA_ISSUE_KEY}") |
| 106 | + elif [[ -z "${CHANGE_URL}" ]]; then |
| 107 | + echo "Full build skipped" > "${WORKSPACE}/${PATCHDIR}/report.html" |
| 108 | + exit 0 |
| 109 | + fi |
| 110 | + YETUS_ARGS+=("--patch-dir=${WORKSPACE}/${PATCHDIR}") |
| 111 | + # where the source is located |
| 112 | + YETUS_ARGS+=("--basedir=${WORKSPACE}/${SOURCEDIR}") |
| 113 | + # our project defaults come from a personality file |
| 114 | + # which will get loaded automatically by setting the project name |
| 115 | + YETUS_ARGS+=("--project=hbase") |
| 116 | + # lots of different output formats |
| 117 | + YETUS_ARGS+=("--brief-report-file=${WORKSPACE}/${PATCHDIR}/brief.txt") |
| 118 | + YETUS_ARGS+=("--console-report-file=${WORKSPACE}/${PATCHDIR}/console.txt") |
| 119 | + YETUS_ARGS+=("--html-report-file=${WORKSPACE}/${PATCHDIR}/report.html") |
| 120 | + # enable writing back to Github |
| 121 | + YETUS_ARGS+=(--github-password="${GITHUB_PASSWORD}") |
| 122 | + YETUS_ARGS+=(--github-user=${GITHUB_USER}) |
| 123 | + # enable writing back to ASF JIRA |
| 124 | + YETUS_ARGS+=(--jira-password="${JIRA_PASSWORD}") |
| 125 | + YETUS_ARGS+=(--jira-user="${JIRA_USER}") |
| 126 | + # auto-kill any surefire stragglers during unit test runs |
| 127 | + YETUS_ARGS+=("--reapermode=kill") |
| 128 | + YETUS_ARGS+=("--multijdktests=compile") |
| 129 | + # set relatively high limits for ASF machines |
| 130 | + # changing these to higher values may cause problems |
| 131 | + # with other jobs on systemd-enabled machines |
| 132 | + YETUS_ARGS+=("--proclimit=10000") |
| 133 | + YETUS_ARGS+=("--dockermemlimit=20g") |
| 134 | + # -1 findbugs issues that show up prior to the patch being applied |
| 135 | + YETUS_ARGS+=("--findbugs-strict-precheck") |
| 136 | + # rsync these files back into the archive dir |
| 137 | + YETUS_ARGS+=("--archive-list=rat.txt") |
| 138 | + # URL for user-side presentation in reports and such to our artifacts |
| 139 | + # (needs to match the archive bits below) |
| 140 | + YETUS_ARGS+=("--build-url-artifacts=artifact/out") |
| 141 | + # plugins to enable |
| 142 | + YETUS_ARGS+=("--plugins=all") |
| 143 | + # don't let these tests cause -1s because we aren't really paying that |
| 144 | + # much attention to them |
| 145 | + YETUS_ARGS+=("--tests-filter=ruby-lint,test4tests") |
| 146 | + # run in docker mode and specifically point to our |
| 147 | + # Dockerfile since we don't want to use the auto-pulled version. |
| 148 | + YETUS_ARGS+=("--docker") |
| 149 | + YETUS_ARGS+=("--dockerfile=${DOCKERFILE}") |
| 150 | + YETUS_ARGS+=("--multijdkdirs=/usr/lib/jvm/java-8-openjdk-amd64") |
| 151 | + YETUS_ARGS+=("--findbugs-home=/usr") |
| 152 | + YETUS_ARGS+=("--whitespace-eol-ignore-list=.*/generated/.*") |
| 153 | + YETUS_ARGS+=("--whitespace-tabs-ignore-list=.*/generated/.*") |
| 154 | + YETUS_ARGS+=("--personality=${SOURCEDIR}/dev-support/hbase-personality.sh") |
| 155 | + YETUS_ARGS+=("--quick-hadoopcheck") |
| 156 | + # effectively treat dev-support as a custom maven module |
| 157 | + YETUS_ARGS+=("--skip-dir=dev-support") |
| 158 | + # help keep the ASF boxes clean |
| 159 | + YETUS_ARGS+=("--sentinel") |
| 160 | + "${TESTPATCHBIN}" "${YETUS_ARGS[@]}" |
| 161 | + ''' |
| 162 | + } |
| 163 | + } |
| 164 | + } |
| 165 | + |
| 166 | + } |
| 167 | + |
| 168 | + post { |
| 169 | + always { |
| 170 | + script { |
| 171 | + // Yetus output |
| 172 | + archiveArtifacts "${env.PATCHDIR}/**" |
| 173 | + // Publish the HTML report so that it can be looked at |
| 174 | + // Has to be relative to WORKSPACE. |
| 175 | + publishHTML (target: [ |
| 176 | + allowMissing: true, |
| 177 | + keepAll: true, |
| 178 | + alwaysLinkToLastBuild: true, |
| 179 | + // Has to be relative to WORKSPACE |
| 180 | + reportDir: "${env.PATCHDIR}", |
| 181 | + reportFiles: 'report.html', |
| 182 | + reportName: 'Yetus Report' |
| 183 | + ]) |
| 184 | + // Publish JUnit results |
| 185 | + try { |
| 186 | + junit "${env.SOURCEDIR}/**/target/surefire-reports/*.xml" |
| 187 | + } catch(e) { |
| 188 | + echo 'junit processing: ' + e.toString() |
| 189 | + } |
| 190 | + } |
| 191 | + } |
| 192 | + |
| 193 | + // Jenkins pipeline jobs fill slaves on PRs without this :( |
| 194 | + cleanup() { |
| 195 | + script { |
| 196 | + sh ''' |
| 197 | + # See YETUS-764 |
| 198 | + if [ -f "${WORKSPACE}/${PATCHDIR}/pidfile.txt" ]; then |
| 199 | + echo "test-patch process appears to still be running: killing" |
| 200 | + kill `cat "${WORKSPACE}/${PATCHDIR}/pidfile.txt"` || true |
| 201 | + sleep 10 |
| 202 | + fi |
| 203 | + if [ -f "${WORKSPACE}/${PATCHDIR}/cidfile.txt" ]; then |
| 204 | + echo "test-patch container appears to still be running: killing" |
| 205 | + docker kill `cat "${WORKSPACE}/${PATCHDIR}/cidfile.txt"` || true |
| 206 | + fi |
| 207 | + # See HADOOP-13951 |
| 208 | + chmod -R u+rxw "${WORKSPACE}" |
| 209 | + ''' |
| 210 | + deleteDir() |
| 211 | + } |
| 212 | + } |
| 213 | + } |
| 214 | +} |
0 commit comments