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

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