Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

create_jobs.groovy 29KB

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