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

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