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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. // This script is used as input to the Jenkins Job DSL plugin to create all the build-jobs that
  2. // Apache POI uses on the public Jenkins instance at https://builds.apache.org/view/P/view/POI/
  3. //
  4. // See https://github.com/jenkinsci/job-dsl-plugin/wiki for information about the DSL, you can
  5. // use http://job-dsl.herokuapp.com/ to validate the code before checkin
  6. //
  7. def triggerSundays = '''
  8. # only run this once per week on Sundays
  9. H H * * 0
  10. '''
  11. def xercesUrl = 'http://repo1.maven.org/maven2/xerces/xercesImpl/2.6.1/xercesImpl-2.6.1.jar'
  12. def xercesLib = 'compile-lib/xercesImpl-2.6.1.jar'
  13. def poijobs = [
  14. [ name: 'POI-DSL-1.8', trigger: 'H */12 * * *'
  15. ],
  16. [ name: 'POI-DSL-OpenJDK', jdk: 'OpenJDK', trigger: 'H */12 * * *',
  17. // H13-H20 (Ubuntu 16.04) do not have OpenJDK 6 installed, see https://issues.apache.org/jira/browse/INFRA-12880
  18. slaveAdd: '&&!beam1&&!beam2&&!beam3&&!beam4&&!beam5&&!beam6&&!beam7&&!beam8' +
  19. '&&!H0&&!H1&&!H2&&!H3&&!H4&&!H5&&!H6&&!H7&&!H8&&!H9&&!H10&&!H11' +
  20. '&&!qnode3' +
  21. '&&!ubuntu-1&&!ubuntu-2&&!ubuntu-4&&!ubuntu-5&&!ubuntu-6&&!ubuntu-eu2&&!ubuntu-us1',
  22. // the JDK is missing on some slaves so builds are unstable
  23. skipcigame: true
  24. ],
  25. [ name: 'POI-DSL-1.9', jdk: '1.9', trigger: triggerSundays,
  26. properties: ['-Djava9addmods=--add-modules=java.xml.bind',
  27. '-Djavadoc9addmods=--add-modules=java.xml.bind',
  28. '-Djava9addmodsvalue=-Dsun.reflect.debugModuleAccessChecks=true',
  29. '-Djava9addopens1=--add-opens=java.xml/com.sun.org.apache.xerces.internal.util=ALL-UNNAMED',
  30. '-Djava9addopens2=--add-opens=java.base/java.io=ALL-UNNAMED',
  31. '-Djava9addopens3=--add-opens=java.base/java.nio=ALL-UNNAMED',
  32. '-Djava9addopens4=--add-opens=java.base/java.lang=ALL-UNNAMED',
  33. '-Djava9addopens5=--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED',
  34. '-Djava.locale.providers=JRE,CLDR'],
  35. skipcigame: true
  36. ],
  37. [ name: 'POI-DSL-IBM-JDK', jdk: 'IBMJDK', trigger: triggerSundays,
  38. // some OOXML tests fail with strange XML parsing errors and missing JCE unlimited strength requirements
  39. disabled: true, skipcigame: true
  40. ],
  41. [ name: 'POI-DSL-old-Xerces', trigger: triggerSundays,
  42. shell: "mkdir -p compile-lib && test -f ${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 9 * * *', maven: true, sonar: true, skipcigame: true
  59. ],
  60. [ name: 'POI-DSL-SonarQube-Gradle', trigger: 'H 9 * * *', gradle: true, sonar: true, skipcigame: true,
  61. disabled: true // this one does run, but does not actually send data to Sonarqube for some reason, we need to investigate some more
  62. ],
  63. [ name: 'POI-DSL-Windows-1.8', trigger: 'H */12 * * *', windows: true, slaves: 'Windows'
  64. ],
  65. ]
  66. def svnBase = 'https://svn.apache.org/repos/asf/poi/trunk'
  67. def defaultJdk = '1.8'
  68. def defaultTrigger = 'H/15 * * * *' // check SCM every 60/15 = 4 minutes
  69. def defaultEmail = 'dev@poi.apache.org'
  70. def defaultAnt = 'Ant 1.9.9'
  71. // currently a lot of H?? slaves don't have Ant installed ... H21 seems to have a SVN problem
  72. def defaultSlaves = 'ubuntu&&!cloud-slave&&!H15&&!H17&&!H18&&!H24&&!ubuntu-4&&!H21'
  73. def jdkMapping = [
  74. '1.8': 'JDK 1.8 (latest)',
  75. '1.9': 'JDK 1.9 (latest)',
  76. 'OpenJDK': 'OpenJDK 8 (on Ubuntu only) ', // blank is required here until the name in the Jenkins instance is fixed!
  77. 'IBMJDK': 'IBM 1.8 64-bit (on Ubuntu only)',
  78. ]
  79. static def shellEx(def context, String cmd, def poijob) {
  80. if (poijob.windows) {
  81. context.batchFile(cmd)
  82. } else {
  83. context.shell(cmd)
  84. }
  85. }
  86. def defaultDesc = '''
  87. <img src="https://poi.apache.org/resources/images/project-logo.jpg" />
  88. <p>
  89. Apache POI - the Java API for Microsoft Documents
  90. </p>
  91. <p>
  92. <b>This is an automatically generated Job Config, do not edit it here!
  93. 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>,
  94. see <a href="https://github.com/jenkinsci/job-dsl-plugin/wiki">https://github.com/jenkinsci/job-dsl-plugin/wiki</a>
  95. for more details about the DSL.</b>
  96. </p>'''
  97. def apicheckDesc = '''
  98. <p>
  99. <b><a href="https://builds.apache.org/analysis/dashboard?id=org.apache.poi%3Apoi-parent&did=1" target="_blank">Sonar reports</a></b> -
  100. <p>
  101. <b><a href="lastSuccessfulBuild/artifact/build/main/build/reports/japi.html">API Check POI</a></b>
  102. <b><a href="lastSuccessfulBuild/artifact/build/ooxml/build/reports/japi.html">API Check POI-OOXML</a></b>
  103. <b><a href="lastSuccessfulBuild/artifact/build/excelant/build/reports/japi.html">API Check POI-Excelant</a></b>
  104. <b><a href="lastSuccessfulBuild/artifact/build/scratchpad/build/reports/japi.html">API Check POI-Scratchpad</a></b>
  105. </p>
  106. '''
  107. def sonarDesc = '''
  108. <p>
  109. <b><a href="lastSuccessfulBuild/findbugsResult/" target="_blank">Findbugs report of latest build</a></b> -
  110. <b><a href="https://builds.apache.org/analysis/dashboard?id=org.apache.poi%3Apoi-parent&did=1" target="_blank">Sonar reports</a></b> -
  111. <b><a href="lastSuccessfulBuild/artifact/build/coverage/index.html" target="_blank">Coverage of latest build</a></b>
  112. </p>
  113. '''
  114. def shellCmdsUnix =
  115. '''# show which files are currently modified in the working copy
  116. svn status
  117. # print out information about which exact version of java we are using
  118. echo Java-Home: $JAVA_HOME
  119. ls -al $JAVA_HOME/
  120. ls -al $JAVA_HOME/bin
  121. $JAVA_HOME/bin/java -version
  122. echo which java
  123. which java
  124. java -version
  125. echo which javac
  126. which javac
  127. javac -version
  128. 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
  129. ant -f build.javacheck.xml -v
  130. POIJOBSHELL
  131. # ignore any error message
  132. exit 0'''
  133. def shellCmdsWin =
  134. '''@echo off
  135. :: show which files are currently modified in the working copy
  136. svn status
  137. :: print out information about which exact version of java we are using
  138. echo Java-Home: %JAVA_HOME%
  139. dir "%JAVA_HOME:\\\\=\\%"
  140. "%JAVA_HOME%/bin/java" -version
  141. POIJOBSHELL
  142. :: ignore any error message
  143. exit /b 0'''
  144. poijobs.each { poijob ->
  145. def jdkKey = poijob.jdk ?: defaultJdk
  146. def trigger = poijob.trigger ?: defaultTrigger
  147. def email = poijob.email ?: defaultEmail
  148. def slaves = poijob.slaves ?: defaultSlaves + (poijob.slaveAdd ?: '')
  149. def antRT = defaultAnt + (poijob.windows ? ' (Windows)' : '')
  150. job(poijob.name) {
  151. if (poijob.disabled) {
  152. disabled()
  153. }
  154. description( defaultDesc + (poijob.apicheck ? apicheckDesc : sonarDesc) )
  155. logRotator {
  156. numToKeep(5)
  157. artifactNumToKeep(1)
  158. }
  159. label(slaves)
  160. environmentVariables {
  161. env('LANG', 'en_US.UTF-8')
  162. if(jdkKey == '1.9') {
  163. // when using JDK 9 for running Ant, we need to provide more packages for the forbidden-api-checks task
  164. 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')
  165. }
  166. }
  167. wrappers {
  168. /* Plugin seems to be missing: Warning: (create_jobs.groovy, line 202) version 1.13 or later of plugin 'build-timeout' needs to be installed
  169. timeout {
  170. absolute(180)
  171. abortBuild()
  172. writeDescription('Build was aborted due to timeout')
  173. }*/
  174. if(poijob.sonar) {
  175. configure { project ->
  176. project / buildWrappers << 'hudson.plugins.sonar.SonarBuildWrapper' {}
  177. }
  178. }
  179. }
  180. jdk(jdkMapping.get(jdkKey))
  181. scm {
  182. svn(svnBase) { svnNode ->
  183. svnNode / browser(class: 'hudson.scm.browsers.ViewSVN') /
  184. url << 'http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN'
  185. }
  186. }
  187. checkoutRetryCount(3)
  188. triggers {
  189. scm(trigger)
  190. }
  191. def shellcmds = (poijob.windows ? shellCmdsWin : shellCmdsUnix).replace('POIJOBSHELL', poijob.shell ?: '')
  192. // Create steps and publishers depending on the type of Job that is selected
  193. if(poijob.maven) {
  194. steps {
  195. shellEx(delegate, shellcmds, poijob)
  196. maven {
  197. goals('clean')
  198. rootPOM('sonar/pom.xml')
  199. localRepository(LocalRepositoryLocation.LOCAL_TO_WORKSPACE)
  200. mavenInstallation('maven-3.2.1')
  201. }
  202. /* Currently not done, let's see if it is still necessary:
  203. # Maven-Download fails for strange reasons, try to workaround...
  204. 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
  205. */
  206. maven {
  207. if(poijob.sonar) {
  208. goals('compile $SONAR_MAVEN_GOAL -Dsonar.host.url=$SONAR_HOST_URL')
  209. } else {
  210. goals('package')
  211. }
  212. rootPOM('sonar/pom.xml')
  213. mavenOpts('-Xmx2g')
  214. mavenOpts('-Xms256m')
  215. mavenOpts('-XX:-OmitStackTraceInFastThrow')
  216. localRepository(LocalRepositoryLocation.LOCAL_TO_WORKSPACE)
  217. mavenInstallation('maven-3.2.1')
  218. }
  219. }
  220. publishers {
  221. if (!poijob.skipcigame) {
  222. configure { project ->
  223. project / publishers << 'hudson.plugins.cigame.GamePublisher' {}
  224. }
  225. }
  226. archiveJunit('sonar/*/target/surefire-reports/TEST-*.xml') {
  227. testDataPublishers {
  228. publishTestStabilityData()
  229. }
  230. }
  231. mailer(email, false, false)
  232. }
  233. } else if (poijob.javadoc) {
  234. steps {
  235. shellEx(delegate, shellcmds, poijob)
  236. ant {
  237. targets(['clean', 'javadocs'] + (poijob.properties ?: []))
  238. prop('coverage.enabled', true)
  239. // Properties did not work, so I had to use targets instead
  240. //properties(poijob.properties ?: '')
  241. antInstallation(antRT)
  242. }
  243. shellEx(delegate, 'zip -r build/javadocs.zip build/tmp/site/build/site/apidocs', poijob)
  244. }
  245. publishers {
  246. if (!poijob.skipcigame) {
  247. configure { project ->
  248. project / publishers << 'hudson.plugins.cigame.GamePublisher' {}
  249. }
  250. }
  251. mailer(email, false, false)
  252. }
  253. } else if (poijob.apicheck) {
  254. steps {
  255. shellEx(delegate, shellcmds, poijob)
  256. gradle {
  257. tasks('japicmp')
  258. useWrapper(false)
  259. }
  260. }
  261. publishers {
  262. archiveArtifacts('build/*/build/reports/japi.html')
  263. if (!poijob.skipcigame) {
  264. configure { project ->
  265. project / publishers << 'hudson.plugins.cigame.GamePublisher' {}
  266. }
  267. }
  268. mailer(email, false, false)
  269. }
  270. } else if(poijob.sonar) {
  271. steps {
  272. shellEx(delegate, shellcmds, poijob)
  273. gradle {
  274. switches('-PenableSonar')
  275. switches('-Dsonar.host.url=$SONAR_HOST_URL')
  276. tasks('sonarqube')
  277. useWrapper(false)
  278. }
  279. }
  280. publishers {
  281. if (!poijob.skipcigame) {
  282. configure { project ->
  283. project / publishers << 'hudson.plugins.cigame.GamePublisher' {}
  284. }
  285. }
  286. mailer(email, false, false)
  287. }
  288. } else {
  289. steps {
  290. shellEx(delegate, shellcmds, poijob)
  291. if(poijob.addShell) {
  292. shellEx(delegate, poijob.addShell, poijob)
  293. }
  294. // For Jobs that should still have the default set of publishers we can configure different steps here
  295. if(poijob.gradle) {
  296. gradle {
  297. tasks('check')
  298. useWrapper(false)
  299. }
  300. } else if (poijob.noScratchpad) {
  301. ant {
  302. targets(['clean', 'compile-all'] + (poijob.properties ?: []))
  303. prop('coverage.enabled', true)
  304. antInstallation(antRT)
  305. }
  306. ant {
  307. targets(['-Dscratchpad.ignore=true', 'jacocotask', 'test-all', 'testcoveragereport'] + (poijob.properties ?: []))
  308. prop('coverage.enabled', true)
  309. antInstallation(antRT)
  310. }
  311. } else {
  312. ant {
  313. targets(['clean', 'jenkins'] + (poijob.properties ?: []))
  314. prop('coverage.enabled', true)
  315. // Properties did not work, so I had to use targets instead
  316. //properties(poijob.properties ?: '')
  317. antInstallation(antRT)
  318. }
  319. ant {
  320. targets(['run'] + (poijob.properties ?: []))
  321. buildFile('src/integrationtest/build.xml')
  322. // Properties did not work, so I had to use targets instead
  323. //properties(poijob.properties ?: '')
  324. antInstallation(antRT)
  325. }
  326. }
  327. }
  328. publishers {
  329. findbugs('build/findbugs.xml', false) {
  330. healthLimits(3, 20)
  331. thresholdLimit('low')
  332. defaultEncoding('UTF-8')
  333. }
  334. // in archive, junit and jacoco publishers, matches beneath build/*/build/... are for Gradle-build results
  335. archiveArtifacts('build/dist/*.tar.gz,build/findbugs.html,build/coverage/**,build/integration-test-results/**,ooxml-lib/**,build/*/build/libs/*.jar')
  336. warnings(['Java Compiler (javac)', 'JavaDoc Tool'], null) {
  337. resolveRelativePaths()
  338. }
  339. 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') {
  340. testDataPublishers {
  341. publishTestStabilityData()
  342. }
  343. }
  344. jacocoCodeCoverage {
  345. classPattern('build/classes,build/excelant-classes,build/ooxml-classes,build/scratchpad-classes,build/*/build/classes')
  346. execPattern('build/*.exec,build/*/build/jacoco/*.exec')
  347. sourcePattern('src/java,src/excelant/java,src/ooxml/java,src/scratchpad/src')
  348. 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')
  349. }
  350. if (!poijob.skipcigame) {
  351. configure { project ->
  352. project / publishers << 'hudson.plugins.cigame.GamePublisher' {}
  353. }
  354. }
  355. mailer(email, false, false)
  356. }
  357. }
  358. }
  359. }
  360. /*
  361. Add a special job which spans a two-dimensional matrix of all JDKs that we want to use and
  362. all slaves that we would like to use and test if the java and ant binaries are available
  363. on that machine correctly.
  364. */
  365. matrixJob('POI-DSL-Test-Environment') {
  366. description(
  367. '''
  368. Check installed version of Java/Ant on all build-nodes
  369. This job is used to verify which machines actually have the required programs installed.
  370. Unfortunately we often see builds break because of changes/new machines...'''
  371. )
  372. /*throttleConcurrentBuilds {
  373. maxPerNode(1)
  374. maxTotal(1)
  375. }*/
  376. logRotator {
  377. numToKeep(5)
  378. artifactNumToKeep(1)
  379. }
  380. axes {
  381. jdk(
  382. 'JDK 1.8 (latest)',
  383. 'OpenJDK 8 (on Ubuntu only) ', // blank is required here until the name in the Jenkins instance is fixed!
  384. 'IBM 1.8 64-bit (on Ubuntu only)',
  385. 'JDK 1.9 (latest)',
  386. 'JDK 9 b181',
  387. 'JDK 9 b181 (unlimited security)'
  388. )
  389. label('Nodes',
  390. 'beam1','beam2','beam3','beam4','beam5','beam6','beam7','beam8',
  391. 'freebsd1',
  392. 'H0','H1','H10','H11','H12','H13','H14','H15','H16','H17','H18','H19','H2','H20','H21','H22','H23','H24','H25','H26','H27','H3','H4','H5','H6','H7','H8','H9',
  393. 'qnode1','qnode2','qnode3',
  394. 'ubuntu-1','ubuntu-2','ubuntu-4','ubuntu-5','ubuntu-6','ubuntu-eu2','ubuntu-eu3','ubuntu-ppc64le','ubuntu-us1',
  395. 'windows-2012-1','windows-2012-2','windows-2012-3'
  396. )
  397. }
  398. steps {
  399. /*if (poijob.windows) {
  400. context.batchFile(cmd)
  401. } else {*/
  402. shell('''
  403. which javac
  404. javac -version
  405. 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
  406. ''')
  407. //}
  408. ant {
  409. antInstallation(defaultAnt)
  410. }
  411. }
  412. publishers {
  413. mailer('centic@poi.apache.org' /* defaultEmail */, false, false)
  414. }
  415. }
  416. /* I tried to put the view into a sub-folder/sub-view, but failed, there are multiple related
  417. plugins so this is all a bit confusing :(, see also https://issues.apache.org/jira/browse/INFRA-14002
  418. dashboardView("P/POI-new") {
  419. columns {
  420. status()
  421. weather()
  422. configureProject()
  423. buildButton()
  424. cronTrigger()
  425. lastBuildConsole()
  426. name()
  427. lastSuccess()
  428. lastFailure()
  429. lastDuration()
  430. //lastSuccessDescription()
  431. jacoco()
  432. }
  433. description("Jobs related to building/testing Apache POI")
  434. filterBuildQueue(false)
  435. filterExecutors(false)
  436. // Job selection
  437. jobs {*/
  438. //regex(/.*POI.*/)
  439. /*}
  440. // Layout
  441. topPortlets {
  442. jenkinsJobsList {
  443. displayName('POI jobs')
  444. }
  445. }
  446. leftPortlets {
  447. testStatisticsChart()
  448. }
  449. rightPortlets {
  450. testTrendChart()
  451. }
  452. bottomPortlets {
  453. testStatisticsGrid()
  454. buildStatistics()
  455. }
  456. }*/