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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  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 or ooxml-lite-report-files are lingering on
  190. svn revert poi*/src/*/java9/module-info.* || true
  191. svn revert src/resources/ooxml-lite-report.* || true
  192. # print out information about which exact version of java we are using
  193. echo Java-Home: $JAVA_HOME
  194. ls -al $JAVA_HOME/
  195. ls -al $JAVA_HOME/bin
  196. $JAVA_HOME/bin/java -version
  197. echo which java
  198. which java
  199. java -version
  200. echo which javac
  201. which javac
  202. javac -version
  203. echo Ant-Home: $ANT_HOME
  204. ls -al $ANT_HOME
  205. echo which ant
  206. which ant || true
  207. ant -version
  208. echo '<project default="test"><target name="test"><echo>Java ${ant.java.version}/${java.version}</echo><exec executable="javac"><arg value="-version"/></exec></target></project>' > build.javacheck.xml
  209. ant -f build.javacheck.xml -v
  210. POIJOBSHELL
  211. # ignore any error message
  212. exit 0'''
  213. def shellCmdsWin =
  214. '''@echo off
  215. :: show which files are currently modified in the working copy
  216. svn status
  217. :: make sure no changed module-class-files are lingering on
  218. svn revert poi*\\src\\*\\java9\\module-info.*
  219. :: print out information about which exact version of java we are using
  220. echo Java-Home: %JAVA_HOME%
  221. dir "%JAVA_HOME:\\\\=\\%"
  222. "%JAVA_HOME%/bin/java" -version
  223. POIJOBSHELL
  224. :: ignore any error message
  225. exit /b 0'''
  226. poijobs.each { poijob ->
  227. def jdkKey = poijob.jdk ?: defaultJdk
  228. def trigger = poijob.trigger ?: defaultTrigger
  229. def email = poijob.email ?: defaultEmail
  230. def slaves = poijob.slaves ?: defaultSlaves + (poijob.slaveAdd ?: '')
  231. def antRT = poijob.windows ? defaultAntWindows : defaultAnt
  232. job('POI/' + poijob.name) {
  233. if (poijob.disabled) {
  234. disabled()
  235. }
  236. description( defaultDesc + (poijob.apicheck ? apicheckDesc : sonarDesc) )
  237. logRotator {
  238. numToKeep(5)
  239. artifactNumToKeep(1)
  240. }
  241. label(slaves)
  242. environmentVariables {
  243. env('LANG', 'en_US.UTF-8')
  244. env('CI_BUILD', 'TRUE')
  245. if(jdkKey == '1.10') {
  246. // when using JDK 9/10 for running Ant, we need to provide more modules for the forbidden-api-checks task
  247. // on JDK 11 and newer there is no such module any more, so do not add it here
  248. 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')
  249. }
  250. env('FORREST_HOME', poijob.windows ? 'f:\\jenkins\\tools\\forrest\\latest' : '/home/jenkins/tools/forrest/latest')
  251. }
  252. wrappers {
  253. timeout {
  254. absolute(300)
  255. abortBuild()
  256. writeDescription('Build was aborted due to timeout')
  257. }
  258. preBuildCleanup {
  259. /* remove xmlbeans while 4.0 is not stable */
  260. includePattern('**/lib/ooxml/xmlbeans*.jar')
  261. includePattern('**/lib/ooxml/ooxml*.jar')
  262. /* remove ooxml-schemas while the builds migrate to 5th edition */
  263. includePattern('build/xmlbean-*/**')
  264. /* remove remaining src debris */
  265. includePattern('src/*/build/**')
  266. }
  267. if(poijob.sonar) {
  268. credentialsBinding {
  269. string('POI_SONAR_TOKEN', 'sonarcloud-poi')
  270. }
  271. configure { project ->
  272. project / buildWrappers << 'hudson.plugins.sonar.SonarBuildWrapper' {}
  273. }
  274. }
  275. }
  276. jdk(jdkMapping.get(jdkKey).jenkinsJdk)
  277. scm {
  278. if (poijob.githubpr) {
  279. git {
  280. remote {
  281. github('apache/poi')
  282. refspec('+refs/pull/*:refs/remotes/origin/pr/*')
  283. }
  284. branch('${sha1}')
  285. }
  286. } else {
  287. svn(svnBase) { svnNode ->
  288. svnNode / browser(class: 'hudson.scm.browsers.ViewSVN') /
  289. url << 'https://svn.apache.org/viewcvs.cgi/?root=Apache-SVN'
  290. }
  291. }
  292. }
  293. checkoutRetryCount(3)
  294. if (poijob.githubpr) {
  295. throttleConcurrentBuilds {
  296. maxPerNode(1)
  297. maxTotal(1)
  298. }
  299. parameters {
  300. /* plugin not available:
  301. gitParam('sha1') {
  302. description('Pull request')
  303. type('BRANCH')
  304. }*/
  305. stringParam('sha1', 'origin/pr/9/head', 'Provide a branch-spec, e.g. origin/pr/9/head')
  306. }
  307. triggers {
  308. pullRequestBuildTrigger()
  309. /*githubPullRequest {
  310. admins(['centic9', 'poi-benchmark', 'tballison', 'gagravarr', 'onealj', 'pjfanning', 'Alain-Bearez'])
  311. userWhitelist(['centic9', 'poi-benchmark', 'tballison', 'gagravarr', 'onealj', 'pjfanning', 'Alain-Bearez'])
  312. orgWhitelist(['apache'])
  313. cron('H/5 * * * *')
  314. triggerPhrase('OK to test')
  315. }*/
  316. }
  317. } else {
  318. triggers {
  319. scm(trigger)
  320. }
  321. }
  322. def shellcmds = (poijob.windows ? shellCmdsWin : shellCmdsUnix).replace('POIJOBSHELL', poijob.shell ?: '')
  323. // Create steps and publishers depending on the type of Job that is selected
  324. if (poijob.javadoc) {
  325. steps {
  326. shellEx(delegate, shellcmds, poijob)
  327. ant {
  328. targets(['clean', 'javadocs'] + (poijob.properties ?: []))
  329. prop('coverage.enabled', true)
  330. // Properties did not work, so I had to use targets instead
  331. //properties(poijob.properties ?: '')
  332. antInstallation(antRT)
  333. }
  334. shellEx(delegate, 'zip -r build/javadocs.zip build/site/apidocs', poijob)
  335. }
  336. publishers {
  337. if (!poijob.skipcigame) {
  338. configure { project ->
  339. project / publishers << 'hudson.plugins.cigame.GamePublisher' {}
  340. }
  341. }
  342. mailer(email, false, false)
  343. }
  344. } else if(poijob.sonar) {
  345. steps {
  346. shellEx(delegate, shellcmds, poijob)
  347. gradle {
  348. switches('-PenableSonar')
  349. switches('-Dsonar.login=${POI_SONAR_TOKEN}')
  350. switches('-Dsonar.organization=apache')
  351. switches('-Dsonar.projectKey=poi-parent')
  352. switches('-Dsonar.host.url=https://sonarcloud.io')
  353. switches("-PjdkVersion=${jdkMapping.get(jdkKey).jdkVersion}")
  354. if (jdkMapping.get(jdkKey).jdkVendor != '') {
  355. switches("-PjdkVendor=${jdkMapping.get(jdkKey).jdkVendor}")
  356. }
  357. tasks('clean')
  358. tasks('check')
  359. tasks('jacocoTestReport')
  360. tasks('sonarqube')
  361. useWrapper(true)
  362. }
  363. }
  364. publishers {
  365. // in archive, junit and jacoco publishers, matches beneath build/*/build/... are for Gradle-build results
  366. archiveArtifacts('build/dist/*.tar.gz,*/build/reports/**,poi-integration/build/test-results/**,*/build/libs/*.jar')
  367. archiveJunit('*/build/test-results/**/TEST-*.xml') {
  368. testDataPublishers {
  369. publishTestStabilityData()
  370. }
  371. }
  372. jacocoCodeCoverage {
  373. classPattern('*/build/classes')
  374. execPattern('*/build/*.exec,*/build/jacoco/*.exec')
  375. sourcePattern('*/src/main/java')
  376. 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')
  377. }
  378. if (!poijob.skipcigame) {
  379. configure { project ->
  380. project / publishers << 'hudson.plugins.cigame.GamePublisher' {}
  381. }
  382. }
  383. mailer(email, false, false)
  384. }
  385. } else {
  386. steps {
  387. shellEx(delegate, shellcmds, poijob)
  388. if(poijob.addShell) {
  389. shellEx(delegate, poijob.addShell, poijob)
  390. }
  391. // For Jobs that should still have the default set of publishers we can configure different steps here
  392. if(poijob.gradle) {
  393. if (!poijob.windows) {
  394. // Gradle will not run any tests if the code is up-to-date, therefore manually mark the files as updated
  395. shellEx(delegate, 'touch --no-create build/*/build/test-results/TEST-*.xml build/*/build/test-results/test/TEST-*.xml', poijob)
  396. }
  397. gradle {
  398. tasks('clean jenkins')
  399. useWrapper(true)
  400. if (poijob.noScratchpad) {
  401. switches('-Pscratchpad.ignore=true')
  402. }
  403. if (poijob.saxonTest) {
  404. switches('-Psaxon.test=true')
  405. }
  406. switches("-PjdkVersion=${jdkMapping.get(jdkKey).jdkVersion}")
  407. if (jdkMapping.get(jdkKey).jdkVendor != '') {
  408. switches("-PjdkVendor=${jdkMapping.get(jdkKey).jdkVendor}")
  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.replace('poi-parent','apache_xmlbeans')) )
  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. if(xjob.sonar) {
  506. credentialsBinding {
  507. string('POI_SONAR_TOKEN', 'sonarcloud-poi')
  508. }
  509. configure { project ->
  510. project / buildWrappers << 'hudson.plugins.sonar.SonarBuildWrapper' {}
  511. }
  512. }
  513. }
  514. jdk(jdkMapping.get(jdkKey).jenkinsJdk)
  515. scm {
  516. svn(xmlbeansSvnBase) { svnNode ->
  517. svnNode / browser(class: 'hudson.scm.browsers.ViewSVN') /
  518. url << 'https://svn.apache.org/viewcvs.cgi/?root=Apache-SVN'
  519. }
  520. }
  521. checkoutRetryCount(3)
  522. triggers {
  523. scm(trigger)
  524. }
  525. def shellcmds = (xjob.windows ? shellCmdsWin : shellCmdsUnix).replace('POIJOBSHELL', xjob.shell ?: '')
  526. // Create steps and publishers depending on the type of Job that is selected
  527. steps {
  528. shellEx(delegate, shellcmds, xjob)
  529. if(xjob.addShell) {
  530. shellEx(delegate, xjob.addShell, xjob)
  531. }
  532. gradle {
  533. if (xjob.sonar) {
  534. switches('-PenableSonar')
  535. switches('-Dsonar.login=${POI_SONAR_TOKEN}')
  536. switches('-Dsonar.organization=apache')
  537. switches('-Dsonar.projectKey=apache_xmlbeans')
  538. switches('-Dsonar.host.url=https://sonarcloud.io')
  539. switches("-PjdkVersion=${jdkMapping.get(jdkKey).jdkVersion}")
  540. if (jdkMapping.get(jdkKey).jdkVendor != '') {
  541. switches("-PjdkVendor=${jdkMapping.get(jdkKey).jdkVendor}")
  542. }
  543. }
  544. tasks('clean')
  545. tasks('jenkins')
  546. tasks('jacocoTestReport')
  547. if (xjob.sonar) {
  548. tasks('sonarqube')
  549. }
  550. useWrapper(true)
  551. }
  552. }
  553. publishers {
  554. archiveArtifacts('build/libs/xmlbeans*.jar,build/distributions/*,build/hs_err*.log')
  555. warnings(['Java Compiler (javac)', 'JavaDoc Tool'], null) {
  556. resolveRelativePaths()
  557. }
  558. archiveJunit('build/test-results/test/TEST-*.xml') {
  559. testDataPublishers {
  560. publishTestStabilityData()
  561. }
  562. }
  563. recordIssues {
  564. tools {
  565. spotBugs {
  566. pattern('build/reports/spotbugs/*/spotbugs.xml')
  567. reportEncoding('UTF-8')
  568. }
  569. }
  570. }
  571. if (!xjob.skipcigame) {
  572. configure { project ->
  573. project / publishers << 'hudson.plugins.cigame.GamePublisher' {}
  574. }
  575. }
  576. mailer(email, false, false)
  577. }
  578. }
  579. }
  580. /*
  581. Add a special job which spans a two-dimensional matrix of all JDKs that we want to use and
  582. all worker nodes that we would like to use and test if the java and ant binaries are available
  583. on that machine correctly.
  584. */
  585. matrixJob('POI/POI-DSL-Test-Environment') {
  586. description(
  587. '''Check installed version of Java/Ant on all build-nodes
  588. This job is used to verify which machines actually have the required programs installed.
  589. Unfortunately we often see builds break because of changes/new machines...''')
  590. /*throttleConcurrentBuilds {
  591. maxPerNode(1)
  592. maxTotal(1)
  593. }*/
  594. logRotator {
  595. numToKeep(1)
  596. artifactNumToKeep(1)
  597. }
  598. axes {
  599. jdk(
  600. 'jdk_1.8_latest',
  601. 'jdk_10_latest',
  602. 'jdk_11_latest',
  603. /* don't look for JDKs that are out of support
  604. 'jdk_12_latest',
  605. 'jdk_13_latest',
  606. 'jdk_14_latest',
  607. 'jdk_15_latest',
  608. 'jdk_16_latest',*/
  609. 'jdk_17_latest',
  610. 'jdk_18_latest',
  611. 'adoptopenjdk_hotspot_8u282',
  612. 'ibmjdk_1.8.0_261'
  613. )
  614. // Note H50 is reserved according to it's node-descripion
  615. 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')
  616. }
  617. steps {
  618. conditionalSteps {
  619. condition {
  620. fileExists('/usr', BaseDir.WORKSPACE)
  621. }
  622. runner('DontRun')
  623. steps {
  624. shell(
  625. '''which svn || true
  626. which javac
  627. javac -version
  628. 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
  629. ''')
  630. ant {
  631. antInstallation(defaultAnt)
  632. }
  633. shell(
  634. '''which mvn || true
  635. mvn -version || true
  636. echo '<project><modelVersion>4.0.0</modelVersion><groupId>org.apache.poi</groupId><artifactId>build-tst</artifactId><version>1.0.0</version></project>' > pom.xml
  637. ''')
  638. maven {
  639. goals('package')
  640. mavenInstallation(defaultMaven)
  641. }
  642. }
  643. }
  644. conditionalSteps {
  645. condition {
  646. fileExists('c:\\windows', BaseDir.WORKSPACE)
  647. }
  648. runner('DontRun')
  649. steps {
  650. batchFile(
  651. '''@echo off
  652. echo .
  653. where javac.exe
  654. echo .
  655. javac -version
  656. echo .
  657. 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
  658. ''')
  659. ant {
  660. antInstallation(defaultAntWindows)
  661. }
  662. }
  663. }
  664. }
  665. }
  666. /* I tried to put the view into a sub-folder/sub-view, but failed, there are multiple related
  667. plugins so this is all a bit confusing :(, see also https://issues.apache.org/jira/browse/INFRA-14002
  668. dashboardView("P/POI-new") {
  669. columns {
  670. status()
  671. weather()
  672. configureProject()
  673. buildButton()
  674. cronTrigger()
  675. lastBuildConsole()
  676. name()
  677. lastSuccess()
  678. lastFailure()
  679. lastDuration()
  680. //lastSuccessDescription()
  681. jacoco()
  682. }
  683. description("<table>\n" +
  684. " <tr>\n" +
  685. " <td><img src=\"https://poi.apache.org/images/project-header.png\" /></td>\n" +
  686. " <td> \n" +
  687. " <p>Apache POI - the Java API for Microsoft Documents</p>\n" +
  688. " <p><b>Most of the POI Jobs are automatically generated by Jenkins Job DSL\n" +
  689. " at <a href=\"https://svn.apache.org/repos/asf/poi/trunk/jenkins\">https://svn.apache.org/repos/asf/poi/trunk/jenkins</a>,<br/>\n" +
  690. " see <a href=\"https://github.com/jenkinsci/job-dsl-plugin/wiki\">https://github.com/jenkinsci/job-dsl-plugin/wiki</a>\n" +
  691. " for more details about the DSL.</b>\n" +
  692. " </p>\n" +
  693. " <p>\n" +
  694. " <b><a href=\"job/POI-DSL-1.8/lastSuccessfulBuild/findbugsResult/\" target=\"_blank\">Findbugs report of latest build</a></b> -\n" +
  695. " <b><a href=\"https://sonarcloud.io/dashboard?id=poi-parent\" target=\"_blank\">Sonar reports</a></b> -\n" +
  696. " <b><a href=\"job/POI-DSL-1.8/lastSuccessfulBuild/artifact/build/coverage/index.html\" target=\"_blank\">Coverage of latest build</a></b>\n" +
  697. " </p>\n" +
  698. " </td>\n" +
  699. " </tr>\n" +
  700. "</table>")
  701. filterBuildQueue(false)
  702. filterExecutors(false)
  703. // Job selection
  704. jobs {*/
  705. //regex(/.*POI.*/)
  706. /*}
  707. // Layout
  708. topPortlets {
  709. jenkinsJobsList {
  710. displayName('POI jobs')
  711. }
  712. }
  713. leftPortlets {
  714. testStatisticsChart()
  715. }
  716. rightPortlets {
  717. testTrendChart()
  718. }
  719. bottomPortlets {
  720. testStatisticsGrid()
  721. buildStatistics()
  722. }
  723. }*/