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

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