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

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