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

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