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

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