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

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