Jenkinsfile 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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. YETUS='yetus'
  29. // Branch or tag name. Yetus release tags are 'rel/X.Y.Z'
  30. YETUS_VERSION='f9ba0170a5787a5f4662d3769804fef0226a182f'
  31. }
  32. parameters {
  33. string(name: 'JIRA_ISSUE_KEY',
  34. defaultValue: '',
  35. description: 'The JIRA issue that has a patch needing pre-commit testing. Example: HADOOP-1234')
  36. }
  37. stages {
  38. stage ('install yetus') {
  39. steps {
  40. dir("${WORKSPACE}/${YETUS}") {
  41. checkout([
  42. $class: 'GitSCM',
  43. branches: [[name: "${env.YETUS_VERSION}"]],
  44. userRemoteConfigs: [[ url: 'https://github.com/apache/yetus.git']]]
  45. )
  46. }
  47. }
  48. }
  49. // Setup codebase so that each platform's build happens in its own exclusive copy of the
  50. // codebase.
  51. // Primarily because YETUS messes up the git branch information and affects the subsequent
  52. // optional stages after the first one.
  53. stage ('setup sources') {
  54. steps {
  55. dir("${WORKSPACE}/centos-8") {
  56. sh '''#!/usr/bin/env bash
  57. cp -Rp ${WORKSPACE}/src ${WORKSPACE}/centos-8
  58. '''
  59. }
  60. dir("${WORKSPACE}/debian-10") {
  61. sh '''#!/usr/bin/env bash
  62. cp -Rp ${WORKSPACE}/src ${WORKSPACE}/debian-10
  63. '''
  64. }
  65. dir("${WORKSPACE}/ubuntu-focal") {
  66. sh '''#!/usr/bin/env bash
  67. cp -Rp ${WORKSPACE}/src ${WORKSPACE}/ubuntu-focal
  68. '''
  69. }
  70. }
  71. }
  72. // This is an optional stage which runs only when there's a change in
  73. // C++/C++ build/platform.
  74. // This stage serves as a means of cross platform validation, which is
  75. // really needed to ensure that any C++ related/platform change doesn't
  76. // break the Hadoop build on Centos 8.
  77. stage ('precommit-run Centos 8') {
  78. environment {
  79. SOURCEDIR = "${WORKSPACE}/centos-8/src"
  80. PATCHDIR = "${WORKSPACE}/centos-8/out"
  81. DOCKERFILE = "${SOURCEDIR}/dev-support/docker/Dockerfile_centos_8"
  82. IS_OPTIONAL = 1
  83. }
  84. steps {
  85. withCredentials(
  86. [usernamePassword(credentialsId: 'apache-hadoop-at-github.com',
  87. passwordVariable: 'GITHUB_TOKEN',
  88. usernameVariable: 'GITHUB_USER'),
  89. usernamePassword(credentialsId: 'hadoopqa-at-asf-jira',
  90. passwordVariable: 'JIRA_PASSWORD',
  91. usernameVariable: 'JIRA_USER')]) {
  92. sh '''#!/usr/bin/env bash
  93. chmod u+x "${SOURCEDIR}/dev-support/jenkins.sh"
  94. "${SOURCEDIR}/dev-support/jenkins.sh" run_ci
  95. '''
  96. }
  97. }
  98. post {
  99. // Since this is an optional platform, we want to copy the artifacts
  100. // and archive it only if the build fails, to help with debugging.
  101. failure {
  102. sh '''#!/usr/bin/env bash
  103. cp -Rp "${WORKSPACE}/centos-8/out" "${WORKSPACE}"
  104. '''
  105. archiveArtifacts "out/**"
  106. }
  107. cleanup() {
  108. script {
  109. sh '''#!/usr/bin/env bash
  110. chmod u+x "${SOURCEDIR}/dev-support/jenkins.sh"
  111. "${SOURCEDIR}/dev-support/jenkins.sh" cleanup_ci_proc
  112. '''
  113. }
  114. }
  115. }
  116. }
  117. // This is an optional stage which runs only when there's a change in
  118. // C++/C++ build/platform.
  119. // This stage serves as a means of cross platform validation, which is
  120. // really needed to ensure that any C++ related/platform change doesn't
  121. // break the Hadoop build on Debian 10.
  122. stage ('precommit-run Debian 10') {
  123. environment {
  124. SOURCEDIR = "${WORKSPACE}/debian-10/src"
  125. PATCHDIR = "${WORKSPACE}/debian-10/out"
  126. DOCKERFILE = "${SOURCEDIR}/dev-support/docker/Dockerfile_debian_10"
  127. IS_OPTIONAL = 1
  128. }
  129. steps {
  130. withCredentials(
  131. [usernamePassword(credentialsId: 'apache-hadoop-at-github.com',
  132. passwordVariable: 'GITHUB_TOKEN',
  133. usernameVariable: 'GITHUB_USER'),
  134. usernamePassword(credentialsId: 'hadoopqa-at-asf-jira',
  135. passwordVariable: 'JIRA_PASSWORD',
  136. usernameVariable: 'JIRA_USER')]) {
  137. sh '''#!/usr/bin/env bash
  138. chmod u+x "${SOURCEDIR}/dev-support/jenkins.sh"
  139. "${SOURCEDIR}/dev-support/jenkins.sh" run_ci
  140. '''
  141. }
  142. }
  143. post {
  144. // Since this is an optional platform, we want to copy the artifacts
  145. // and archive it only if the build fails, to help with debugging.
  146. failure {
  147. sh '''#!/usr/bin/env bash
  148. cp -Rp "${WORKSPACE}/debian-10/out" "${WORKSPACE}"
  149. '''
  150. archiveArtifacts "out/**"
  151. }
  152. cleanup() {
  153. script {
  154. sh '''#!/usr/bin/env bash
  155. chmod u+x "${SOURCEDIR}/dev-support/jenkins.sh"
  156. "${SOURCEDIR}/dev-support/jenkins.sh" cleanup_ci_proc
  157. '''
  158. }
  159. }
  160. }
  161. }
  162. // We want to use Ubuntu Focal as our main CI and thus, this stage
  163. // isn't optional (runs for all the PRs).
  164. stage ('precommit-run Ubuntu focal') {
  165. environment {
  166. SOURCEDIR = "${WORKSPACE}/ubuntu-focal/src"
  167. PATCHDIR = "${WORKSPACE}/ubuntu-focal/out"
  168. DOCKERFILE = "${SOURCEDIR}/dev-support/docker/Dockerfile"
  169. IS_OPTIONAL = 0
  170. }
  171. steps {
  172. withCredentials(
  173. [usernamePassword(credentialsId: 'apache-hadoop-at-github.com',
  174. passwordVariable: 'GITHUB_TOKEN',
  175. usernameVariable: 'GITHUB_USER'),
  176. usernamePassword(credentialsId: 'hadoopqa-at-asf-jira',
  177. passwordVariable: 'JIRA_PASSWORD',
  178. usernameVariable: 'JIRA_USER')]) {
  179. sh '''#!/usr/bin/env bash
  180. chmod u+x "${SOURCEDIR}/dev-support/jenkins.sh"
  181. "${SOURCEDIR}/dev-support/jenkins.sh" run_ci
  182. '''
  183. }
  184. }
  185. post {
  186. always {
  187. script {
  188. // Publish status if it was missed (YETUS-1059)
  189. withCredentials(
  190. [usernamePassword(credentialsId: '683f5dcf-5552-4b28-9fb1-6a6b77cf53dd',
  191. passwordVariable: 'GITHUB_TOKEN',
  192. usernameVariable: 'GITHUB_USER')]) {
  193. sh '''#!/usr/bin/env bash
  194. # Copy the artifacts of Ubuntu focal build to workspace
  195. cp -Rp "${WORKSPACE}/ubuntu-focal/out" "${WORKSPACE}"
  196. # Send Github status
  197. chmod u+x "${SOURCEDIR}/dev-support/jenkins.sh"
  198. "${SOURCEDIR}/dev-support/jenkins.sh" github_status_recovery
  199. '''
  200. }
  201. // YETUS output
  202. archiveArtifacts "out/**"
  203. // Publish the HTML report so that it can be looked at
  204. // Has to be relative to WORKSPACE.
  205. publishHTML (target: [
  206. allowMissing: true,
  207. keepAll: true,
  208. alwaysLinkToLastBuild: true,
  209. // Has to be relative to WORKSPACE
  210. reportDir: "out",
  211. reportFiles: 'report.html',
  212. reportName: 'Yetus Report'
  213. ])
  214. // Publish JUnit results
  215. try {
  216. junit "${SOURCEDIR}/**/target/surefire-reports/*.xml"
  217. } catch(e) {
  218. echo 'junit processing: ' + e.toString()
  219. }
  220. }
  221. }
  222. cleanup() {
  223. script {
  224. sh '''#!/usr/bin/env bash
  225. chmod u+x "${SOURCEDIR}/dev-support/jenkins.sh"
  226. "${SOURCEDIR}/dev-support/jenkins.sh" cleanup_ci_proc
  227. '''
  228. }
  229. }
  230. }
  231. }
  232. }
  233. post {
  234. // Jenkins pipeline jobs fill slaves on PRs without this :(
  235. cleanup() {
  236. script {
  237. sh '''#!/usr/bin/env bash
  238. # See HADOOP-13951
  239. chmod -R u+rxw "${WORKSPACE}"
  240. '''
  241. deleteDir()
  242. }
  243. }
  244. }
  245. }