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

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