You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

create_jobs.groovy 32KB

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