Jenkinsfile 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. pipeline {
  18. agent {
  19. label 'Hadoop'
  20. }
  21. options {
  22. buildDiscarder(logRotator(numToKeepStr: '5'))
  23. timeout (time: 24, unit: 'HOURS')
  24. timestamps()
  25. checkoutToSubdirectory('src')
  26. }
  27. environment {
  28. SOURCEDIR = 'src'
  29. // will also need to change notification section below
  30. PATCHDIR = 'out'
  31. YETUS='yetus'
  32. // Branch or tag name. Yetus release tags are 'rel/X.Y.Z'
  33. YETUS_VERSION='f9ba0170a5787a5f4662d3769804fef0226a182f'
  34. }
  35. parameters {
  36. string(name: 'JIRA_ISSUE_KEY',
  37. defaultValue: '',
  38. description: 'The JIRA issue that has a patch needing pre-commit testing. Example: HADOOP-1234')
  39. }
  40. stages {
  41. stage ('install yetus') {
  42. steps {
  43. dir("${WORKSPACE}/${YETUS}") {
  44. checkout([
  45. $class: 'GitSCM',
  46. branches: [[name: "${env.YETUS_VERSION}"]],
  47. userRemoteConfigs: [[ url: 'https://github.com/apache/yetus.git']]]
  48. )
  49. }
  50. }
  51. }
  52. // This is an optional stage which runs only when there's a change in
  53. // C++/C++ build/platform.
  54. // This stage serves as a means of cross platform validation, which is
  55. // really needed to ensure that any C++ related/platform change doesn't
  56. // break the Hadoop build on Centos 8.
  57. stage ('precommit-run Centos 8') {
  58. environment {
  59. DOCKERFILE = "${SOURCEDIR}/dev-support/docker/Dockerfile_centos_8"
  60. IS_OPTIONAL = 1
  61. }
  62. steps {
  63. withCredentials(
  64. [usernamePassword(credentialsId: 'apache-hadoop-at-github.com',
  65. passwordVariable: 'GITHUB_TOKEN',
  66. usernameVariable: 'GITHUB_USER'),
  67. usernamePassword(credentialsId: 'hadoopqa-at-asf-jira',
  68. passwordVariable: 'JIRA_PASSWORD',
  69. usernameVariable: 'JIRA_USER')]) {
  70. sh '''#!/usr/bin/env bash
  71. chmod u+x "${SOURCEDIR}/dev-support/jenkins.sh"
  72. "${SOURCEDIR}/dev-support/jenkins.sh"
  73. '''
  74. }
  75. }
  76. }
  77. // This is an optional stage which runs only when there's a change in
  78. // C++/C++ build/platform.
  79. // This stage serves as a means of cross platform validation, which is
  80. // really needed to ensure that any C++ related/platform change doesn't
  81. // break the Hadoop build on Debian 10.
  82. stage ('precommit-run Debian 10') {
  83. environment {
  84. DOCKERFILE = "${SOURCEDIR}/dev-support/docker/Dockerfile_debian_10"
  85. IS_OPTIONAL = 1
  86. }
  87. steps {
  88. withCredentials(
  89. [usernamePassword(credentialsId: 'apache-hadoop-at-github.com',
  90. passwordVariable: 'GITHUB_TOKEN',
  91. usernameVariable: 'GITHUB_USER'),
  92. usernamePassword(credentialsId: 'hadoopqa-at-asf-jira',
  93. passwordVariable: 'JIRA_PASSWORD',
  94. usernameVariable: 'JIRA_USER')]) {
  95. sh '''#!/usr/bin/env bash
  96. chmod u+x "${SOURCEDIR}/dev-support/jenkins.sh"
  97. "${SOURCEDIR}/dev-support/jenkins.sh"
  98. '''
  99. }
  100. }
  101. }
  102. // We want to use Ubuntu Focal as our main CI and thus, this stage
  103. // isn't optional (runs for all the PRs).
  104. stage ('precommit-run Ubuntu focal') {
  105. environment {
  106. DOCKERFILE = "${SOURCEDIR}/dev-support/docker/Dockerfile"
  107. IS_OPTIONAL = 0
  108. }
  109. steps {
  110. withCredentials(
  111. [usernamePassword(credentialsId: 'apache-hadoop-at-github.com',
  112. passwordVariable: 'GITHUB_TOKEN',
  113. usernameVariable: 'GITHUB_USER'),
  114. usernamePassword(credentialsId: 'hadoopqa-at-asf-jira',
  115. passwordVariable: 'JIRA_PASSWORD',
  116. usernameVariable: 'JIRA_USER')]) {
  117. sh '''#!/usr/bin/env bash
  118. chmod u+x "${SOURCEDIR}/dev-support/jenkins.sh"
  119. "${SOURCEDIR}/dev-support/jenkins.sh"
  120. '''
  121. }
  122. }
  123. }
  124. }
  125. post {
  126. always {
  127. script {
  128. // Publish status if it was missed (YETUS-1059)
  129. withCredentials(
  130. [usernamePassword(credentialsId: '683f5dcf-5552-4b28-9fb1-6a6b77cf53dd',
  131. passwordVariable: 'GITHUB_TOKEN',
  132. usernameVariable: 'GITHUB_USER')]) {
  133. sh '''#!/usr/bin/env bash
  134. YETUS_ARGS+=("--github-token=${GITHUB_TOKEN}")
  135. YETUS_ARGS+=("--patch-dir=${WORKSPACE}/${PATCHDIR}")
  136. TESTPATCHBIN="${WORKSPACE}/${YETUS}/precommit/src/main/shell/github-status-recovery.sh"
  137. /usr/bin/env bash "${TESTPATCHBIN}" "${YETUS_ARGS[@]}" ${EXTRA_ARGS} || true
  138. '''
  139. }
  140. // Yetus output
  141. archiveArtifacts "${env.PATCHDIR}/**"
  142. // Publish the HTML report so that it can be looked at
  143. // Has to be relative to WORKSPACE.
  144. publishHTML (target: [
  145. allowMissing: true,
  146. keepAll: true,
  147. alwaysLinkToLastBuild: true,
  148. // Has to be relative to WORKSPACE
  149. reportDir: "${env.PATCHDIR}",
  150. reportFiles: 'report.html',
  151. reportName: 'Yetus Report'
  152. ])
  153. // Publish JUnit results
  154. try {
  155. junit "${env.SOURCEDIR}/**/target/surefire-reports/*.xml"
  156. } catch(e) {
  157. echo 'junit processing: ' + e.toString()
  158. }
  159. }
  160. }
  161. // Jenkins pipeline jobs fill slaves on PRs without this :(
  162. cleanup() {
  163. script {
  164. sh '''
  165. # See YETUS-764
  166. if [ -f "${WORKSPACE}/${PATCHDIR}/pidfile.txt" ]; then
  167. echo "test-patch process appears to still be running: killing"
  168. kill `cat "${WORKSPACE}/${PATCHDIR}/pidfile.txt"` || true
  169. sleep 10
  170. fi
  171. if [ -f "${WORKSPACE}/${PATCHDIR}/cidfile.txt" ]; then
  172. echo "test-patch container appears to still be running: killing"
  173. docker kill `cat "${WORKSPACE}/${PATCHDIR}/cidfile.txt"` || true
  174. fi
  175. # See HADOOP-13951
  176. chmod -R u+rxw "${WORKSPACE}"
  177. '''
  178. deleteDir()
  179. }
  180. }
  181. }
  182. }