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

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