You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

create_jobs.groovy 33KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784
  1. // This script is used as input to the Jenkins Job DSL plugin to create all the build-jobs that
  2. // Apache POI uses on the public Jenkins instance at https://ci-builds.apache.org/job/POI/
  3. //
  4. // See https://github.com/jenkinsci/job-dsl-plugin/wiki for information about the DSL, you can
  5. // use https://job-dsl.herokuapp.com/ to validate the code before checkin
  6. //
  7. def triggerSundays = '''
  8. # only run this once per week on Sundays
  9. H H * * 0
  10. '''
  11. def xercesUrl = 'https://repo1.maven.org/maven2/xerces/xercesImpl/2.6.1/xercesImpl-2.6.1.jar'
  12. def xercesLib = './xercesImpl-2.6.1.jar'
  13. def poijobs = [
  14. [ name: 'POI-DSL-1.8', trigger: 'H */12 * * *', gradle: true
  15. ],
  16. [ name: 'POI-DSL-OpenJDK', jdk: 'OpenJDK 1.8', trigger: 'H */12 * * *',
  17. // only a limited set of nodes still have OpenJDK 8 (on Ubuntu) installed
  18. slaves: 'ubuntu',
  19. skipcigame: true, gradle: true
  20. ],
  21. // [ name: 'POI-DSL-1.10', jdk: '1.10', trigger: triggerSundays, skipcigame: true,
  22. // // let's save some CPU cycles here, 10 had EOL in September 2018
  23. // disabled: true
  24. // ],
  25. [ name: 'POI-DSL-1.11', jdk: '1.11', trigger: triggerSundays, skipcigame: true, gradle: true
  26. ],
  27. // [ name: 'POI-DSL-1.12', jdk: '1.12', trigger: triggerSundays, skipcigame: true,
  28. // // let's save some CPU cycles here, 12 is not a LTS and JDK 13 is GA as of 17 September 2019
  29. // disabled: true
  30. // ],
  31. // [ name: 'POI-DSL-1.13', jdk: '1.13', trigger: triggerSundays, skipcigame: true,
  32. // // let's save some CPU cycles here, 13 is not a LTS and JDK 14 is GA as of 17 March 2020
  33. // disabled: true
  34. // ],
  35. // [ name: 'POI-DSL-1.14', jdk: '1.14', trigger: triggerSundays, skipcigame: true,
  36. // // let's save some CPU cycles here, 14 is not a LTS and JDK 15 is GA as of 15 September 2020
  37. // disabled: true
  38. // ],
  39. [ name: 'POI-DSL-1.15', jdk: '1.15', trigger: triggerSundays, skipcigame: true, gradle: true,
  40. // let's save some CPU cycles here, 15 is not a LTS and JDK 16 is GA
  41. disabled: true
  42. ],
  43. [ name: 'POI-DSL-1.16', jdk: '1.16', trigger: 'H */12 * * *', skipcigame: true, gradle: true,
  44. // let's save some CPU cycles here, 16 is not a LTS and JDK 17 is GA
  45. disabled: true
  46. ],
  47. [ name: 'POI-DSL-1.17', jdk: '1.17', trigger: 'H */12 * * *', skipcigame: true, gradle: true
  48. ],
  49. [ name: 'POI-DSL-1.18', jdk: '1.18', trigger: triggerSundays, skipcigame: true, gradle: true
  50. ],
  51. //Gradle 7.5 does not support Java 19 (change to gradle: true when we have Gradle support)
  52. [ name: 'POI-DSL-1.19', jdk: '1.19', trigger: triggerSundays, skipcigame: true, gradle: false
  53. ],
  54. [ name: 'POI-DSL-IBM-JDK', jdk: 'IBMJDK', trigger: triggerSundays, skipcigame: true, gradle: true
  55. ],
  56. [ name: 'POI-DSL-old-Xerces', trigger: triggerSundays, skipcigame: true,
  57. shell: "test -s ${xercesLib} || wget -O ${xercesLib} ${xercesUrl}\n",
  58. // the property triggers using Xerces as XML Parser and previously showed some exception that can occur
  59. properties: ["-Dadditionaljar=${xercesLib}"]
  60. ],
  61. // [ name: 'POI-DSL-Maven', trigger: 'H */4 * * *', maven: true,
  62. // // not needed any more now that we use Gradle for SonarQube
  63. // disabled: true
  64. // ],
  65. [ name: 'POI-DSL-regenerate-javadoc', trigger: triggerSundays, javadoc: true
  66. ],
  67. // it was impossible to make this run stable in Gradle, thus disabling this for now
  68. [ name: 'POI-DSL-API-Check', trigger: '@daily', apicheck: true, disabled: true
  69. ],
  70. // [ name: 'POI-DSL-Gradle', trigger: triggerSundays, email: 'centic@apache.org', gradle: true
  71. // ],
  72. [ name: 'POI-DSL-no-scratchpad', trigger: triggerSundays, noScratchpad: true, gradle: true
  73. ],
  74. [ name: 'POI-DSL-saxon-test', trigger: triggerSundays, saxonTest: true, gradle: true
  75. ],
  76. // [ name: 'POI-DSL-SonarQube', jdk: '1.11', trigger: 'H 7 * * *', maven: true, sonar: true, skipcigame: true,
  77. // email: 'kiwiwings@apache.org',
  78. // // replaced by Gradle-based build now
  79. // disabled: true
  80. // ],
  81. [ name: 'POI-DSL-SonarQube-Gradle', jdk: '1.11', trigger: 'H 7 * * *', gradle: true, sonar: true, skipcigame: true
  82. ],
  83. [ name: 'POI-DSL-Windows-1.8', trigger: 'H */12 * * *', windows: true, slaves: 'Windows', gradle: true
  84. ],
  85. // [ name: 'POI-DSL-Windows-1.12', jdk: '1.12', trigger: triggerSundays, windows: true, slaves: 'Windows', skipcigame: true, gradle: true,
  86. // // let's save some CPU cycles here, 12 is not a LTS and JDK 13 is GA now
  87. // disabled: true
  88. // ],
  89. // [ name: 'POI-DSL-Windows-1.14', jdk: '1.14', trigger: triggerSundays, windows: true, slaves: 'Windows', skipcigame: true, gradle: true,
  90. // // let's only verify the latest two JDKs
  91. // disabled: true
  92. // ],
  93. [ name: 'POI-DSL-Windows-1.15', jdk: '1.15', trigger: triggerSundays, windows: true, slaves: 'Windows', skipcigame: true, gradle: true,
  94. // let's save some CPU cycles here, 14 is not a LTS and JDK 15 is GA as of 15 September 2020
  95. disabled: true
  96. ],
  97. [ name: 'POI-DSL-Windows-1.16', jdk: '1.16', trigger: 'H */12 * * *', windows: true, slaves: 'Windows', skipcigame: true, gradle: true,
  98. // let's save some CPU cycles here, 16 is not a LTS and JDK 17 is GA
  99. disabled: true
  100. ],
  101. [ name: 'POI-DSL-Windows-1.17', jdk: '1.17', trigger: 'H */12 * * *', windows: true, slaves: 'Windows', skipcigame: true, gradle: true
  102. ],
  103. [ name: 'POI-DSL-Windows-1.18', jdk: '1.18', trigger: triggerSundays, windows: true, slaves: 'Windows', skipcigame: true, gradle: true
  104. ],
  105. [ name: 'POI-DSL-Github-PullRequests', trigger: '', githubpr: true, skipcigame: true,
  106. // ensure the file which is needed from the separate documentation module does exist
  107. // as we are checking out from git, we do not have the reference checked out here
  108. addShell: 'mkdir -p src/documentation\ntouch src/documentation/RELEASE-NOTES.txt'
  109. ],
  110. ]
  111. def xmlbeansjobs = [
  112. [ name: 'POI-XMLBeans-DSL-1.8', jdk: '1.8', trigger: 'H */12 * * *', skipcigame: true, gradle: true,
  113. ],
  114. [ name: 'POI-XMLBeans-DSL-1.11', jdk: '1.11', trigger: triggerSundays, skipcigame: true, gradle: true,
  115. ],
  116. [ name: 'POI-XMLBeans-DSL-1.16', jdk: '1.16', trigger: triggerSundays, skipcigame: true, gradle: true,
  117. // let's save some CPU cycles here, 16 is not a LTS and JDK 17 is GA
  118. disabled: true
  119. ],
  120. [ name: 'POI-XMLBeans-DSL-1.17', jdk: '1.17', trigger: triggerSundays, skipcigame: true, gradle: true,
  121. ],
  122. [ name: 'POI-XMLBeans-DSL-1.18', jdk: '1.18', trigger: triggerSundays, skipcigame: true, gradle: true,
  123. ],
  124. [ name: 'POI-XMLBeans-DSL-Sonar', jdk: '1.11', trigger: triggerSundays, skipcigame: true,
  125. sonar: true
  126. ]
  127. ]
  128. def svnBase = 'https://svn.apache.org/repos/asf/poi/trunk'
  129. def xmlbeansSvnBase = 'https://svn.apache.org/repos/asf/xmlbeans/trunk'
  130. def defaultJdk = '1.8'
  131. def defaultTrigger = 'H/15 * * * *' // check SCM every 60/15 = 4 minutes
  132. def defaultEmail = 'dev@poi.apache.org'
  133. def defaultAnt = 'ant_1.10_latest'
  134. def defaultAntWindows = 'ant_1.10_latest_windows'
  135. def defaultMaven = 'maven_3_latest'
  136. // H29 seems to have very little memory
  137. def defaultSlaves = '(ubuntu)&&!beam&&!cloud-slave&&!H29'
  138. def jdkMapping = [
  139. '1.8': [ jenkinsJdk: 'jdk_1.8_latest', jdkVersion: 8, jdkVendor: 'oracle' ],
  140. '1.10': [ jenkinsJdk: 'jdk_10_latest', jdkVersion: 10, jdkVendor: 'oracle' ],
  141. '1.11': [ jenkinsJdk: 'jdk_11_latest', jdkVersion: 11, jdkVendor: 'oracle' ],
  142. '1.12': [ jenkinsJdk: 'jdk_12_latest', jdkVersion: 12, jdkVendor: '' ],
  143. '1.13': [ jenkinsJdk: 'jdk_13_latest', jdkVersion: 13, jdkVendor: '' ],
  144. '1.14': [ jenkinsJdk: 'jdk_14_latest', jdkVersion: 14, jdkVendor: '' ],
  145. '1.15': [ jenkinsJdk: 'jdk_15_latest', jdkVersion: 15, jdkVendor: '' ],
  146. '1.16': [ jenkinsJdk: 'jdk_16_latest', jdkVersion: 16, jdkVendor: '' ],
  147. '1.17': [ jenkinsJdk: 'jdk_17_latest', jdkVersion: 17, jdkVendor: '' ],
  148. '1.18': [ jenkinsJdk: 'jdk_18_latest', jdkVersion: 18, jdkVendor: '' ],
  149. '1.19': [ jenkinsJdk: 'jdk_19_latest', jdkVersion: 19, jdkVendor: '' ],
  150. 'OpenJDK 1.8': [ jenkinsJdk: 'adoptopenjdk_hotspot_8u282', jdkVersion: 8, jdkVendor: 'adoptopenjdk' ],
  151. 'IBMJDK': [ jenkinsJdk: 'ibmjdk_1.8.0_261', jdkVersion: 8, jdkVendor: 'ibm' ]
  152. ]
  153. static def shellEx(def context, String cmd, def poijob) {
  154. if (poijob.windows) {
  155. context.batchFile(cmd)
  156. } else {
  157. context.shell(cmd)
  158. }
  159. }
  160. def defaultDesc = '''
  161. <img src="https://poi.apache.org/images/project-header.png" />
  162. <p>
  163. Apache POI - the Java API for Microsoft Documents
  164. </p>
  165. <p>
  166. <b>This is an automatically generated Job Config, do not edit it here!
  167. Instead change the Jenkins Job DSL at <a href="https://svn.apache.org/repos/asf/poi/trunk/jenkins">https://svn.apache.org/repos/asf/poi/trunk/jenkins</a>,
  168. see <a href="https://github.com/jenkinsci/job-dsl-plugin/wiki">https://github.com/jenkinsci/job-dsl-plugin/wiki</a>
  169. for more details about the DSL.</b>
  170. </p>'''
  171. def apicheckDesc = '''
  172. <p>
  173. <b><a href="https://sonarcloud.io/dashboard?id=poi-parent" target="_blank">Sonar reports</a></b> -
  174. <p>
  175. <b><a href="lastSuccessfulBuild/artifact/build/poi/build/reports/japi.html">API Check POI</a></b>
  176. <b><a href="lastSuccessfulBuild/artifact/build/poi-ooxml/build/reports/japi.html">API Check POI-OOXML</a></b>
  177. <b><a href="lastSuccessfulBuild/artifact/build/poi-excelant/build/reports/japi.html">API Check POI-Excelant</a></b>
  178. <b><a href="lastSuccessfulBuild/artifact/build/poi-scratchpad/build/reports/japi.html">API Check POI-Scratchpad</a></b>
  179. </p>
  180. '''
  181. def sonarDesc = '''
  182. <p>
  183. <b><a href="lastSuccessfulBuild/findbugsResult/" target="_blank">Findbugs report of latest build</a></b> -
  184. <b><a href="https://sonarcloud.io/dashboard?id=poi-parent" target="_blank">Sonar reports</a></b> -
  185. <b><a href="lastSuccessfulBuild/artifact/build/coverage/index.html" target="_blank">Coverage of latest build</a></b>
  186. </p>
  187. '''
  188. def shellCmdsUnix =
  189. '''# remove some outdated directories that should not be there any more
  190. rm -rf examples excelant integrationtest main ooxml ooxml-schema scratchpad build.javacheck.xml
  191. # show which files are currently modified in the working copy
  192. svn status || true
  193. # make sure no changed module-class-files or ooxml-lite-report-files are lingering on
  194. svn revert poi*/src/*/java9/module-info.* || true
  195. svn revert src/resources/ooxml-lite-report.* || true
  196. # print out information about which exact version of java we are using
  197. echo Java-Home: $JAVA_HOME
  198. ls -al $JAVA_HOME/
  199. ls -al $JAVA_HOME/bin
  200. $JAVA_HOME/bin/java -version
  201. echo which java
  202. which java
  203. java -version
  204. echo which javac
  205. which javac
  206. javac -version
  207. echo Ant-Home: $ANT_HOME
  208. ls -al $ANT_HOME
  209. echo which ant
  210. which ant || true
  211. ant -version
  212. echo '<project default="test"><target name="test"><echo>Java ${ant.java.version}/${java.version}</echo><exec executable="javac"><arg value="-version"/></exec></target></project>' > build.javacheck.xml
  213. ant -f build.javacheck.xml -v
  214. POIJOBSHELL
  215. # ignore any error message
  216. exit 0'''
  217. def shellCmdsWin =
  218. '''@echo off
  219. :: show which files are currently modified in the working copy
  220. svn status
  221. :: make sure no changed module-class-files are lingering on
  222. svn revert poi*\\src\\*\\java9\\module-info.*
  223. :: print out information about which exact version of java we are using
  224. echo Java-Home: %JAVA_HOME%
  225. dir "%JAVA_HOME:\\\\=\\%"
  226. "%JAVA_HOME%/bin/java" -version
  227. POIJOBSHELL
  228. :: ignore any error message
  229. exit /b 0'''
  230. poijobs.each { poijob ->
  231. def jdkKey = poijob.jdk ?: defaultJdk
  232. def trigger = poijob.trigger ?: defaultTrigger
  233. def email = poijob.email ?: defaultEmail
  234. def slaves = poijob.slaves ?: defaultSlaves + (poijob.slaveAdd ?: '')
  235. def antRT = poijob.windows ? defaultAntWindows : defaultAnt
  236. job('POI/' + poijob.name) {
  237. if (poijob.disabled) {
  238. disabled()
  239. }
  240. description( defaultDesc + (poijob.apicheck ? apicheckDesc : sonarDesc) )
  241. logRotator {
  242. numToKeep(5)
  243. artifactNumToKeep(1)
  244. }
  245. label(slaves)
  246. environmentVariables {
  247. env('LANG', 'en_US.UTF-8')
  248. env('CI_BUILD', 'TRUE')
  249. if(jdkKey == '1.10') {
  250. // when using JDK 9/10 for running Ant, we need to provide more modules for the forbidden-api-checks task
  251. // on JDK 11 and newer there is no such module any more, so do not add it here
  252. env('ANT_OPTS', '--add-modules=java.xml.bind --add-opens=java.xml/com.sun.org.apache.xerces.internal.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED')
  253. }
  254. env('FORREST_HOME', poijob.windows ? 'f:\\jenkins\\tools\\forrest\\latest' : '/home/jenkins/tools/forrest/latest')
  255. }
  256. wrappers {
  257. timeout {
  258. absolute(300)
  259. abortBuild()
  260. writeDescription('Build was aborted due to timeout')
  261. }
  262. preBuildCleanup {
  263. /* remove xmlbeans while 4.0 is not stable */
  264. includePattern('**/lib/ooxml/xmlbeans*.jar')
  265. includePattern('**/lib/ooxml/ooxml*.jar')
  266. /* remove ooxml-schemas while the builds migrate to 5th edition */
  267. includePattern('build/xmlbean-*/**')
  268. /* remove remaining src debris */
  269. includePattern('src/*/build/**')
  270. }
  271. if(poijob.sonar) {
  272. credentialsBinding {
  273. string('POI_SONAR_TOKEN', 'sonarcloud-poi')
  274. }
  275. configure { project ->
  276. project / buildWrappers << 'hudson.plugins.sonar.SonarBuildWrapper' {}
  277. }
  278. }
  279. }
  280. jdk(jdkMapping.get(jdkKey).jenkinsJdk)
  281. scm {
  282. if (poijob.githubpr) {
  283. git {
  284. remote {
  285. github('apache/poi')
  286. refspec('+refs/pull/*:refs/remotes/origin/pr/*')
  287. }
  288. branch('${sha1}')
  289. }
  290. } else {
  291. svn(svnBase) { svnNode ->
  292. svnNode / browser(class: 'hudson.scm.browsers.ViewSVN') /
  293. url << 'https://svn.apache.org/viewcvs.cgi/?root=Apache-SVN'
  294. }
  295. }
  296. }
  297. checkoutRetryCount(3)
  298. if (poijob.githubpr) {
  299. throttleConcurrentBuilds {
  300. maxPerNode(1)
  301. maxTotal(1)
  302. }
  303. parameters {
  304. /* plugin not available:
  305. gitParam('sha1') {
  306. description('Pull request')
  307. type('BRANCH')
  308. }*/
  309. stringParam('sha1', 'origin/pr/9/head', 'Provide a branch-spec, e.g. origin/pr/9/head')
  310. }
  311. triggers {
  312. pullRequestBuildTrigger()
  313. /*githubPullRequest {
  314. admins(['centic9', 'poi-benchmark', 'tballison', 'gagravarr', 'onealj', 'pjfanning', 'Alain-Bearez'])
  315. userWhitelist(['centic9', 'poi-benchmark', 'tballison', 'gagravarr', 'onealj', 'pjfanning', 'Alain-Bearez'])
  316. orgWhitelist(['apache'])
  317. cron('H/5 * * * *')
  318. triggerPhrase('OK to test')
  319. }*/
  320. }
  321. } else {
  322. triggers {
  323. scm(trigger)
  324. }
  325. }
  326. def shellcmds = (poijob.windows ? shellCmdsWin : shellCmdsUnix).replace('POIJOBSHELL', poijob.shell ?: '')
  327. // Create steps and publishers depending on the type of Job that is selected
  328. if (poijob.javadoc) {
  329. steps {
  330. shellEx(delegate, shellcmds, poijob)
  331. ant {
  332. targets(['clean', 'javadocs'] + (poijob.properties ?: []))
  333. prop('coverage.enabled', true)
  334. // Properties did not work, so I had to use targets instead
  335. //properties(poijob.properties ?: '')
  336. antInstallation(antRT)
  337. }
  338. shellEx(delegate, 'zip -r build/javadocs.zip build/site/apidocs', poijob)
  339. }
  340. publishers {
  341. if (!poijob.skipcigame) {
  342. configure { project ->
  343. project / publishers << 'hudson.plugins.cigame.GamePublisher' {}
  344. }
  345. }
  346. mailer(email, false, false)
  347. }
  348. } else if(poijob.sonar) {
  349. steps {
  350. shellEx(delegate, shellcmds, poijob)
  351. gradle {
  352. switches('-PenableSonar')
  353. switches('-Dsonar.login=${POI_SONAR_TOKEN}')
  354. switches('-Dsonar.organization=apache')
  355. switches('-Dsonar.projectKey=poi-parent')
  356. switches('-Dsonar.host.url=https://sonarcloud.io')
  357. switches("-PjdkVersion=${jdkMapping.get(jdkKey).jdkVersion}")
  358. if (jdkMapping.get(jdkKey).jdkVendor != '') {
  359. switches("-PjdkVendor=${jdkMapping.get(jdkKey).jdkVendor}")
  360. }
  361. tasks('clean')
  362. tasks('check')
  363. tasks('jacocoTestReport')
  364. tasks('sonarqube')
  365. useWrapper(true)
  366. }
  367. }
  368. publishers {
  369. // in archive, junit and jacoco publishers, matches beneath build/*/build/... are for Gradle-build results
  370. archiveArtifacts('build/dist/*.tar.gz,*/build/reports/**,poi-integration/build/test-results/**,*/build/libs/*.jar')
  371. archiveJunit('*/build/test-results/**/TEST-*.xml') {
  372. testDataPublishers {
  373. publishTestStabilityData()
  374. }
  375. }
  376. jacocoCodeCoverage {
  377. classPattern('*/build/classes')
  378. execPattern('*/build/*.exec,*/build/jacoco/*.exec')
  379. sourcePattern('*/src/main/java')
  380. exclusionPattern('com/microsoft/**,org/openxmlformats/**,org/etsi/**,org/w3/**,schemaorg*/**,schemasMicrosoft*/**,org/apache/poi/hdf/model/hdftypes/definitions/*.class,org/apache/poi/hwpf/model/types/*.class,org/apache/poi/hssf/usermodel/DummyGraphics2d.class,org/apache/poi/sl/draw/binding/*.class')
  381. }
  382. if (!poijob.skipcigame) {
  383. configure { project ->
  384. project / publishers << 'hudson.plugins.cigame.GamePublisher' {}
  385. }
  386. }
  387. mailer(email, false, false)
  388. }
  389. } else {
  390. steps {
  391. shellEx(delegate, shellcmds, poijob)
  392. if(poijob.addShell) {
  393. shellEx(delegate, poijob.addShell, poijob)
  394. }
  395. // For Jobs that should still have the default set of publishers we can configure different steps here
  396. if(poijob.gradle) {
  397. if (!poijob.windows) {
  398. // Gradle will not run any tests if the code is up-to-date, therefore manually mark the files as updated
  399. shellEx(delegate, 'touch --no-create build/*/build/test-results/TEST-*.xml build/*/build/test-results/test/TEST-*.xml', poijob)
  400. }
  401. gradle {
  402. tasks('clean jenkins')
  403. useWrapper(true)
  404. if (poijob.noScratchpad) {
  405. switches('-Pscratchpad.ignore=true')
  406. }
  407. if (poijob.saxonTest) {
  408. switches('-Psaxon.test=true')
  409. }
  410. switches("-PjdkVersion=${jdkMapping.get(jdkKey).jdkVersion}")
  411. if (jdkMapping.get(jdkKey).jdkVendor != '') {
  412. switches("-PjdkVendor=${jdkMapping.get(jdkKey).jdkVendor}")
  413. }
  414. }
  415. } else {
  416. ant {
  417. targets(['clean', 'jenkins'] + (poijob.properties ?: []))
  418. prop('coverage.enabled', true)
  419. // Properties did not work, so I had to use targets instead
  420. //properties(poijob.properties ?: '')
  421. antInstallation(antRT)
  422. }
  423. ant {
  424. targets(['run'] + (poijob.properties ?: []))
  425. buildFile('poi-integration/build.xml')
  426. // Properties did not work, so I had to use targets instead
  427. //properties(poijob.properties ?: '')
  428. antInstallation(antRT)
  429. }
  430. }
  431. }
  432. publishers {
  433. recordIssues {
  434. tools {
  435. spotBugs {
  436. pattern('*/build/reports/spotbugs/*.xml')
  437. reportEncoding('UTF-8')
  438. }
  439. }
  440. }
  441. // in archive, junit and jacoco publishers, matches beneath build/*/build/... are for Gradle-build results
  442. archiveArtifacts('build/dist/*.zip,build/dist/*.tgz,build/dist/maven/*/*.jar,build/coverage/**,build/hs_err*.log')
  443. warnings(['Java Compiler (javac)', 'JavaDoc Tool'], null) {
  444. resolveRelativePaths()
  445. }
  446. archiveJunit('*/build/test-results/**/TEST-*.xml') {
  447. testDataPublishers {
  448. publishTestStabilityData()
  449. }
  450. }
  451. jacocoCodeCoverage {
  452. classPattern('*/build/classes')
  453. execPattern('*/build/*.exec,*/build/jacoco/*.exec')
  454. sourcePattern('*/src/main/java')
  455. exclusionPattern('com/microsoft/**,org/openxmlformats/**,org/etsi/**,org/w3/**,schemaorg*/**,schemasMicrosoft*/**,org/apache/poi/hdf/model/hdftypes/definitions/*.class,org/apache/poi/hwpf/model/types/*.class,org/apache/poi/hssf/usermodel/DummyGraphics2d.class,org/apache/poi/sl/draw/binding/*.class')
  456. }
  457. if (!poijob.skipcigame) {
  458. configure { project ->
  459. project / publishers << 'hudson.plugins.cigame.GamePublisher' {}
  460. }
  461. }
  462. mailer(email, false, false)
  463. }
  464. }
  465. if (poijob.githubpr) {
  466. configure {
  467. it / 'properties' << 'com.cloudbees.jenkins.plugins.git.vmerge.JobPropertyImpl'(plugin: 'git-validated-merge') {
  468. credentialsId('ASF_Cloudbees_Jenkins_ci-builds')
  469. postBuildPushFailureHandler(class: 'com.cloudbees.jenkins.plugins.git.vmerge.pbph.PushFailureIsFailure')
  470. }
  471. }
  472. }
  473. }
  474. }
  475. xmlbeansjobs.each { xjob ->
  476. def jdkKey = xjob.jdk ?: defaultJdk
  477. def trigger = xjob.trigger ?: defaultTrigger
  478. def email = xjob.email ?: defaultEmail
  479. def slaves = xjob.slaves ?: defaultSlaves + (xjob.slaveAdd ?: '')
  480. def antRT = xjob.windows ? defaultAntWindows : defaultAnt
  481. job('POI/' + xjob.name) {
  482. if (xjob.disabled) {
  483. disabled()
  484. }
  485. description( defaultDesc + (xjob.apicheck ? apicheckDesc : sonarDesc.replace('poi-parent','apache_xmlbeans')) )
  486. logRotator {
  487. numToKeep(5)
  488. artifactNumToKeep(1)
  489. }
  490. label(slaves)
  491. environmentVariables {
  492. env('LANG', 'en_US.UTF-8')
  493. if(jdkKey == '1.10') {
  494. // when using JDK 9/10 for running Ant, we need to provide more modules for the forbidden-api-checks task
  495. // on JDK 11 and newer there is no such module any more, so do not add it here
  496. env('ANT_OPTS', '--add-modules=java.xml.bind --add-opens=java.xml/com.sun.org.apache.xerces.internal.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED')
  497. } else if (jdkKey == '1.11' || jdkKey == '1.12' || jdkKey == '1.13' || jdkKey == '1.14' || jdkKey == '1.15' || jdkKey == '1.16' || jdkKey == '1.17' || jdkKey == '1.18' || jdkKey == '1.19') {
  498. env('ANT_OPTS', '--add-opens=java.xml/com.sun.org.apache.xerces.internal.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED')
  499. }
  500. // will be needed for forbidden-apis-check: env('ANT_HOME', xjob.windows ? 'f:\\jenkins\\tools\\ant\\latest' : '/usr/share/ant')
  501. env('FORREST_HOME', xjob.windows ? 'f:\\jenkins\\tools\\forrest\\latest' : '/home/jenkins/tools/forrest/latest')
  502. }
  503. wrappers {
  504. timeout {
  505. absolute(180)
  506. abortBuild()
  507. writeDescription('Build was aborted due to timeout')
  508. }
  509. if(xjob.sonar) {
  510. credentialsBinding {
  511. string('POI_SONAR_TOKEN', 'sonarcloud-poi')
  512. }
  513. configure { project ->
  514. project / buildWrappers << 'hudson.plugins.sonar.SonarBuildWrapper' {}
  515. }
  516. }
  517. }
  518. jdk(jdkMapping.get(jdkKey).jenkinsJdk)
  519. scm {
  520. svn(xmlbeansSvnBase) { svnNode ->
  521. svnNode / browser(class: 'hudson.scm.browsers.ViewSVN') /
  522. url << 'https://svn.apache.org/viewcvs.cgi/?root=Apache-SVN'
  523. }
  524. }
  525. checkoutRetryCount(3)
  526. triggers {
  527. scm(trigger)
  528. }
  529. def shellcmds = (xjob.windows ? shellCmdsWin : shellCmdsUnix).replace('POIJOBSHELL', xjob.shell ?: '')
  530. // Create steps and publishers depending on the type of Job that is selected
  531. steps {
  532. shellEx(delegate, shellcmds, xjob)
  533. if(xjob.addShell) {
  534. shellEx(delegate, xjob.addShell, xjob)
  535. }
  536. gradle {
  537. if (xjob.sonar) {
  538. switches('-PenableSonar')
  539. switches('-Dsonar.login=${POI_SONAR_TOKEN}')
  540. switches('-Dsonar.organization=apache')
  541. switches('-Dsonar.projectKey=apache_xmlbeans')
  542. switches('-Dsonar.host.url=https://sonarcloud.io')
  543. switches("-PjdkVersion=${jdkMapping.get(jdkKey).jdkVersion}")
  544. if (jdkMapping.get(jdkKey).jdkVendor != '') {
  545. switches("-PjdkVendor=${jdkMapping.get(jdkKey).jdkVendor}")
  546. }
  547. }
  548. tasks('clean')
  549. tasks('jenkins')
  550. tasks('jacocoTestReport')
  551. if (xjob.sonar) {
  552. tasks('sonarqube')
  553. }
  554. useWrapper(true)
  555. }
  556. }
  557. publishers {
  558. archiveArtifacts('build/libs/xmlbeans*.jar,build/distributions/*,build/hs_err*.log')
  559. warnings(['Java Compiler (javac)', 'JavaDoc Tool'], null) {
  560. resolveRelativePaths()
  561. }
  562. archiveJunit('build/test-results/test/TEST-*.xml') {
  563. testDataPublishers {
  564. publishTestStabilityData()
  565. }
  566. }
  567. recordIssues {
  568. tools {
  569. spotBugs {
  570. pattern('build/reports/spotbugs/*/spotbugs.xml')
  571. reportEncoding('UTF-8')
  572. }
  573. }
  574. }
  575. if (!xjob.skipcigame) {
  576. configure { project ->
  577. project / publishers << 'hudson.plugins.cigame.GamePublisher' {}
  578. }
  579. }
  580. mailer(email, false, false)
  581. }
  582. }
  583. }
  584. /*
  585. Add a special job which spans a two-dimensional matrix of all JDKs that we want to use and
  586. all worker nodes that we would like to use and test if the java and ant binaries are available
  587. on that machine correctly.
  588. */
  589. matrixJob('POI/POI-DSL-Test-Environment') {
  590. description(
  591. '''Check installed version of Java/Ant on all build-nodes
  592. This job is used to verify which machines actually have the required programs installed.
  593. Unfortunately we often see builds break because of changes/new machines...''')
  594. /*throttleConcurrentBuilds {
  595. maxPerNode(1)
  596. maxTotal(1)
  597. }*/
  598. logRotator {
  599. numToKeep(1)
  600. artifactNumToKeep(1)
  601. }
  602. axes {
  603. jdk(
  604. 'jdk_1.8_latest',
  605. 'jdk_10_latest',
  606. 'jdk_11_latest',
  607. /* don't look for JDKs that are out of support
  608. 'jdk_12_latest',
  609. 'jdk_13_latest',
  610. 'jdk_14_latest',
  611. 'jdk_15_latest',
  612. 'jdk_16_latest',*/
  613. 'jdk_17_latest',
  614. 'jdk_18_latest',
  615. 'jdk_19_latest',
  616. 'adoptopenjdk_hotspot_8u282',
  617. 'ibmjdk_1.8.0_261'
  618. )
  619. // Note H50 is reserved according to it's node-descripion
  620. label('Nodes','H22','H23','H24','H25','H26','H27','H28','H29','H30','H31','H32','H33','H34','H35','H36','H37','H38','H39','H40','H41','H42','H43','H44','H48','lucene1','lucene2','master')
  621. }
  622. steps {
  623. conditionalSteps {
  624. condition {
  625. fileExists('/usr', BaseDir.WORKSPACE)
  626. }
  627. runner('DontRun')
  628. steps {
  629. shell(
  630. '''which svn || true
  631. which javac
  632. javac -version
  633. echo '<?xml version="1.0"?><project name="POI Build" default="test"><target name="test"><echo>Using Ant: ${ant.version} from ${ant.home}</echo></target></project>' > build.xml
  634. ''')
  635. ant {
  636. antInstallation(defaultAnt)
  637. }
  638. shell(
  639. '''which mvn || true
  640. mvn -version || true
  641. echo '<project><modelVersion>4.0.0</modelVersion><groupId>org.apache.poi</groupId><artifactId>build-tst</artifactId><version>1.0.0</version></project>' > pom.xml
  642. ''')
  643. maven {
  644. goals('package')
  645. mavenInstallation(defaultMaven)
  646. }
  647. }
  648. }
  649. conditionalSteps {
  650. condition {
  651. fileExists('c:\\windows', BaseDir.WORKSPACE)
  652. }
  653. runner('DontRun')
  654. steps {
  655. batchFile(
  656. '''@echo off
  657. echo .
  658. where javac.exe
  659. echo .
  660. javac -version
  661. echo .
  662. echo ^<?xml version=^"1.0^"?^>^<project name=^"POI Build^" default=^"test^"^>^<target name=^"test^"^>^<echo^>Using Ant: ${ant.version} from ${ant.home}, ant detected Java ${ant.java.version} (may be different than actual Java sometimes...), using Java: ${java.version}/${java.runtime.version}/${java.vm.version}/${java.vm.name} from ${java.vm.vendor} on ${os.name}: ${os.version}^</echo^>^</target^>^</project^> > build.xml
  663. ''')
  664. ant {
  665. antInstallation(defaultAntWindows)
  666. }
  667. }
  668. }
  669. }
  670. }
  671. /* I tried to put the view into a sub-folder/sub-view, but failed, there are multiple related
  672. plugins so this is all a bit confusing :(, see also https://issues.apache.org/jira/browse/INFRA-14002
  673. dashboardView("P/POI-new") {
  674. columns {
  675. status()
  676. weather()
  677. configureProject()
  678. buildButton()
  679. cronTrigger()
  680. lastBuildConsole()
  681. name()
  682. lastSuccess()
  683. lastFailure()
  684. lastDuration()
  685. //lastSuccessDescription()
  686. jacoco()
  687. }
  688. description("<table>\n" +
  689. " <tr>\n" +
  690. " <td><img src=\"https://poi.apache.org/images/project-header.png\" /></td>\n" +
  691. " <td> \n" +
  692. " <p>Apache POI - the Java API for Microsoft Documents</p>\n" +
  693. " <p><b>Most of the POI Jobs are automatically generated by Jenkins Job DSL\n" +
  694. " at <a href=\"https://svn.apache.org/repos/asf/poi/trunk/jenkins\">https://svn.apache.org/repos/asf/poi/trunk/jenkins</a>,<br/>\n" +
  695. " see <a href=\"https://github.com/jenkinsci/job-dsl-plugin/wiki\">https://github.com/jenkinsci/job-dsl-plugin/wiki</a>\n" +
  696. " for more details about the DSL.</b>\n" +
  697. " </p>\n" +
  698. " <p>\n" +
  699. " <b><a href=\"job/POI-DSL-1.8/lastSuccessfulBuild/findbugsResult/\" target=\"_blank\">Findbugs report of latest build</a></b> -\n" +
  700. " <b><a href=\"https://sonarcloud.io/dashboard?id=poi-parent\" target=\"_blank\">Sonar reports</a></b> -\n" +
  701. " <b><a href=\"job/POI-DSL-1.8/lastSuccessfulBuild/artifact/build/coverage/index.html\" target=\"_blank\">Coverage of latest build</a></b>\n" +
  702. " </p>\n" +
  703. " </td>\n" +
  704. " </tr>\n" +
  705. "</table>")
  706. filterBuildQueue(false)
  707. filterExecutors(false)
  708. // Job selection
  709. jobs {*/
  710. //regex(/.*POI.*/)
  711. /*}
  712. // Layout
  713. topPortlets {
  714. jenkinsJobsList {
  715. displayName('POI jobs')
  716. }
  717. }
  718. leftPortlets {
  719. testStatisticsChart()
  720. }
  721. rightPortlets {
  722. testTrendChart()
  723. }
  724. bottomPortlets {
  725. testStatisticsGrid()
  726. buildStatistics()
  727. }
  728. }*/