jenkinsfile-windows-10 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. def getGithubCreds() {
  18. return [usernamePassword(credentialsId: 'apache-hadoop-at-github.com',
  19. passwordVariable: 'GITHUB_TOKEN',
  20. usernameVariable: 'GITHUB_USER')]
  21. }
  22. // Publish JUnit results only if there are XML files under surefire-reports
  23. def publishJUnitResults() {
  24. def findCmdExitCode = sh script: "find ${SOURCEDIR} -wholename */target/surefire-reports/*.xml | egrep .", returnStatus: true
  25. boolean surefireReportsExist = findCmdExitCode == 0
  26. if (surefireReportsExist) {
  27. echo "XML files found under surefire-reports, running junit"
  28. // The path should be relative to WORKSPACE for the junit.
  29. SRC = "${SOURCEDIR}/**/target/surefire-reports/*.xml".replace("$WORKSPACE/","")
  30. try {
  31. junit "${SRC}"
  32. } catch(e) {
  33. echo 'junit processing: ' + e.toString()
  34. }
  35. } else {
  36. echo "No XML files found under surefire-reports, skipping junit"
  37. }
  38. }
  39. pipeline {
  40. agent {
  41. label 'Windows'
  42. }
  43. options {
  44. buildDiscarder(logRotator(numToKeepStr: '15'))
  45. timeout (time: 72, unit: 'HOURS')
  46. timestamps()
  47. checkoutToSubdirectory('src')
  48. }
  49. environment {
  50. YETUS='yetus'
  51. // Branch or tag name. Yetus release tags are 'rel/X.Y.Z'
  52. YETUS_VERSION='rel/0.14.0'
  53. }
  54. parameters {
  55. string(name: 'JIRA_ISSUE_KEY',
  56. defaultValue: '',
  57. description: 'The JIRA issue that has a patch needing pre-commit testing. Example: HADOOP-1234')
  58. }
  59. stages {
  60. stage ('Install Yetus') {
  61. steps {
  62. dir("${WORKSPACE}/${YETUS}") {
  63. checkout([
  64. $class: 'GitSCM',
  65. branches: [[name: "${env.YETUS_VERSION}"]],
  66. userRemoteConfigs: [[ url: 'https://github.com/apache/yetus.git']]]
  67. )
  68. }
  69. }
  70. }
  71. stage ('Windows 10') {
  72. environment {
  73. SOURCEDIR = "${WORKSPACE}/src"
  74. PATCHDIR = "${WORKSPACE}/out"
  75. DOCKERFILE = "${SOURCEDIR}/dev-support/docker/Dockerfile_windows_10"
  76. DOCKER_BUILDKIT = 0
  77. IS_OPTIONAL = 0
  78. IS_NIGHTLY_BUILD = 0
  79. IS_WINDOWS = 1
  80. }
  81. steps {
  82. withCredentials(getGithubCreds()) {
  83. bat 'if not exist %WORKSPACE%\\out mkdir %WORKSPACE%\\out'
  84. bat 'if not exist F:\\maven\\repository mkdir F:\\maven\\repository'
  85. bat '''docker build --label org.apache.yetus=""^
  86. --label org.apache.yetus.testpatch.project=hadoop^
  87. --tag hadoop-windows-10-builder^
  88. -f %DOCKERFILE% %SOURCEDIR%\\dev-support\\docker'''
  89. bat '''docker run --rm -v %WORKSPACE%\\out:C:\\out^
  90. -v %WORKSPACE%\\src:C:\\src^
  91. -v %WORKSPACE%\\yetus:C:\\yetus^
  92. -v F:\\maven\\repository:C:\\Users\\%BUILD_USER%\\.m2^
  93. -e BUILD_URL=%BUILD_URL% -e BRANCH_NAME=%BRANCH_NAME%^
  94. -e JOB_NAME=%JOB_NAME% -e JENKINS_URL=%JENKINS_URL%^
  95. -e CHANGE_URL=%CHANGE_URL% -e WORKSPACE=/c -e YETUS=yetus^
  96. -e BUILD_NUMBER=%BUILD_NUMBER% -e EXECUTOR_NUMBER=%EXECUTOR_NUMBER%^
  97. -e BUILD_ID=%BUILD_ID% -e GIT_COMMIT=%GIT_COMMIT%^
  98. -e NODE_NAME=%NODE_NAME% -e GIT_URL=%GIT_URL%^
  99. -e BUILD_TAG=%BUILD_TAG% -e GIT_BRANCH=%GIT_BRANCH%^
  100. -e PATCH_OR_ISSUE=%CHANGE_URL% -e JIRA_ISSUE_KEY=%JIRA_ISSUE_KEY%^
  101. -e IS_OPTIONAL=0 -e SOURCEDIR=/c/hadoop -e PATCHDIR=/c/out^
  102. -e GITHUB_TOKEN=%GITHUB_TOKEN% -e GITHUB_USER=%GITHUB_USER%^
  103. -e IS_NIGHTLY_BUILD=%IS_NIGHTLY_BUILD% -e IS_WINDOWS=%IS_WINDOWS%^
  104. -e BASH_EXECUTABLE=/c/Git/bin/bash.exe^
  105. -e VCPKG_INSTALLED_PACKAGES=/c/vcpkg/installed/x64-windows^
  106. -e CMAKE_TOOLCHAIN_FILE=/c/vcpkg/scripts/buildsystems/vcpkg.cmake^
  107. hadoop-windows-10-builder "/c" "xcopy" "/s" "/e" "/h" "/y" "/i" "/q" "C:\\src" "C:\\hadoop"^
  108. "&&" "C:\\Git\\bin\\bash.exe" "-c" \'"/c/src/dev-support/jenkins.sh" "run_ci"\'
  109. '''
  110. }
  111. }
  112. post {
  113. always {
  114. script {
  115. bat '''docker run --rm --user ContainerAdministrator^
  116. -v %WORKSPACE%\\out:C:\\out^
  117. hadoop-windows-10-builder "/c" "icacls" "C:\\out" "/c" "/t" "/q" "/grant" "Users:F"
  118. '''
  119. bat '''docker run --rm --user ContainerAdministrator^
  120. -v F:\\maven\\repository:C:\\Users\\%BUILD_USER%\\.m2^
  121. hadoop-windows-10-builder "/c" "icacls" "C:\\Users\\%BUILD_USER%\\.m2" "/c" "/t" "/q" "/grant" "Users:F"
  122. '''
  123. // Publish status if it was missed (YETUS-1059)
  124. withCredentials(
  125. [usernamePassword(credentialsId: '683f5dcf-5552-4b28-9fb1-6a6b77cf53dd',
  126. passwordVariable: 'GITHUB_TOKEN',
  127. usernameVariable: 'GITHUB_USER')]) {
  128. bat '''docker run --rm -v %WORKSPACE%\\out:C:\\out^
  129. -v %WORKSPACE%\\src:C:\\src^
  130. -v %WORKSPACE%\\yetus:C:\\yetus^
  131. -v F:\\maven\\repository:C:\\Users\\%BUILD_USER%\\.m2^
  132. -e BUILD_URL=%BUILD_URL% -e BRANCH_NAME=%BRANCH_NAME%^
  133. -e JOB_NAME=%JOB_NAME% -e JENKINS_URL=%JENKINS_URL%^
  134. -e CHANGE_URL=%CHANGE_URL% -e WORKSPACE=/c -e YETUS=yetus^
  135. -e BUILD_NUMBER=%BUILD_NUMBER% -e EXECUTOR_NUMBER=%EXECUTOR_NUMBER%^
  136. -e BUILD_ID=%BUILD_ID% -e GIT_COMMIT=%GIT_COMMIT%^
  137. -e NODE_NAME=%NODE_NAME% -e GIT_URL=%GIT_URL%^
  138. -e BUILD_TAG=%BUILD_TAG% -e GIT_BRANCH=%GIT_BRANCH%^
  139. -e PATCH_OR_ISSUE=%CHANGE_URL% -e JIRA_ISSUE_KEY=%JIRA_ISSUE_KEY%^
  140. -e IS_OPTIONAL=0 -e SOURCEDIR=/c/hadoop -e PATCHDIR=/c/out^
  141. -e GITHUB_TOKEN=%GITHUB_TOKEN% -e GITHUB_USER=%GITHUB_USER%^
  142. -e IS_NIGHTLY_BUILD=%IS_NIGHTLY_BUILD% -e IS_WINDOWS=%IS_WINDOWS%^
  143. -e BASH_EXECUTABLE=/c/Git/bin/bash.exe^
  144. -e VCPKG_INSTALLED_PACKAGES=/c/vcpkg/installed/x64-windows^
  145. -e CMAKE_TOOLCHAIN_FILE=/c/vcpkg/scripts/buildsystems/vcpkg.cmake^
  146. hadoop-windows-10-builder "/c"^
  147. "C:\\Git\\bin\\bash.exe" "-c" \'"/c/src/dev-support/jenkins.sh" "github_status_recovery"\'
  148. '''
  149. }
  150. archiveArtifacts "out/**"
  151. publishJUnitResults()
  152. // Publish the HTML report so that it can be looked at
  153. // Has to be relative to WORKSPACE.
  154. publishHTML (target: [
  155. allowMissing: true,
  156. keepAll: true,
  157. alwaysLinkToLastBuild: true,
  158. // Has to be relative to WORKSPACE
  159. reportDir: "out",
  160. reportFiles: 'report.html',
  161. reportName: 'Yetus Report'
  162. ])
  163. }
  164. }
  165. cleanup() {
  166. script {
  167. bat '''
  168. C:\\PROGRA~1\\Git\\bin\\bash.exe -c "chmod u+x ${SOURCEDIR}/dev-support/jenkins.sh"
  169. C:\\PROGRA~1\\Git\\bin\\bash.exe -c "${SOURCEDIR}/dev-support/jenkins.sh cleanup_ci_proc"
  170. '''
  171. }
  172. }
  173. }
  174. }
  175. }
  176. post {
  177. // Jenkins pipeline jobs fill slaves on PRs without this :(
  178. cleanup() {
  179. script {
  180. deleteDir()
  181. }
  182. }
  183. }
  184. }