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

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