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 32KB

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