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

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