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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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/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 poijobs = [
  12. [ name: 'POI-DSL-1.6',
  13. // workaround as Sourceforge does not accept any of the SSL ciphers in JDK 6 any more and thus we cannot download this jar
  14. // as part of the Ant build
  15. addShell: 'wget -O lib/findbugs-noUpdateChecks-2.0.3.zip http://downloads.sourceforge.net/project/findbugs/findbugs/2.0.3/findbugs-noUpdateChecks-2.0.3.zip?download='
  16. ],
  17. [ name: 'POI-DSL-1.8', jdk: '1.8', trigger: 'H */12 * * *',
  18. // ubuntu-4 repeatedely failed during Findbugs results collection
  19. slaveAdd: '&&!ubuntu-4'
  20. ],
  21. [ name: 'POI-DSL-OpenJDK', jdk: 'OpenJDK', trigger: 'H */12 * * *',
  22. // H13-H20 (Ubuntu 16.04) do not have OpenJDK 6 installed, see https://issues.apache.org/jira/browse/INFRA-12880
  23. slaveAdd: '&&!H13&&!H14&&!H15&&!H16&&!H17&&!H18&&!H19&&!H20&&!ubuntu-eu2',
  24. // the JDK is missing on some slaves so builds are unstable
  25. skipcigame: true
  26. ],
  27. [ name: 'POI-DSL-1.9', jdk: '1.9', trigger: triggerSundays,
  28. properties: ['-Dmaxpermsize=-Dthis.is.a.dummy=true',
  29. '-Djava9addmods=--add-modules=java.xml.bind',
  30. '-Djavadoc9addmods=--add-modules=java.xml.bind',
  31. '-Djava9addmodsvalue=-Dsun.reflect.debugModuleAccessChecks=true',
  32. '-Djava9addopens1=--add-opens=java.base/com.sun.org.apache.xerces.internal.util=ALL-UNNAMED',
  33. '-Djava9addopens2=--add-opens=java.base/java.io=ALL-UNNAMED',
  34. '-Djava9addopens3=--add-opens=java.base/java.nio=ALL-UNNAMED',
  35. '-Djava9addopens4=--add-opens=java.base/java.lang=ALL-UNNAMED',
  36. '-Djava.locale.providers=JRE,CLDR'],
  37. skipcigame: true
  38. ],
  39. [ name: 'POI-DSL-IBM-JDK', jdk: 'IBMJDK', trigger: triggerSundays,
  40. // some OOXML tests fail with strange XML parsing errors and missing JCE unlimited strength requirements
  41. disabled: true, skipcigame: true
  42. ],
  43. [ name: 'POI-DSL-old-Xerces', trigger: triggerSundays,
  44. shell: 'mkdir -p compile-lib && test -f compile-lib/xercesImpl-2.6.1.jar || wget -O compile-lib/xercesImpl-2.6.1.jar http://repo1.maven.org/maven2/xerces/xercesImpl/2.6.1/xercesImpl-2.6.1.jar\n',
  45. // the property triggers using Xerces as XML Parser and previously showed some exception that can occur
  46. properties: ['-Dadditionaljar=compile-lib/xercesImpl-2.6.1.jar'],
  47. // workaround as Sourceforge does not accept any of the SSL ciphers in JDK 6 any more and thus we cannot download this jar
  48. // as part of the Ant build
  49. addShell: 'wget -O lib/findbugs-noUpdateChecks-2.0.3.zip http://downloads.sourceforge.net/project/findbugs/findbugs/2.0.3/findbugs-noUpdateChecks-2.0.3.zip?download='
  50. ],
  51. [ name: 'POI-DSL-Maven', trigger: 'H */4 * * *', maven: true
  52. ],
  53. [ name: 'POI-DSL-regenerate-javadoc', trigger: triggerSundays, javadoc: true
  54. ],
  55. [ name: 'POI-DSL-API-Check', jdk: '1.7', trigger: '@daily', apicheck: true
  56. ],
  57. [ name: 'POI-DSL-Gradle', jdk: '1.7', trigger: triggerSundays, email: 'centic@apache.org', gradle: true,
  58. // Gradle will not run any tests if the code is up-to-date, therefore manually mark the files as updated
  59. addShell: 'touch --no-create build/*/build/test-results/test/TEST-*.xml'
  60. ],
  61. [ name: 'POI-DSL-no-scratchpad', trigger: triggerSundays, noScratchpad: true
  62. ],
  63. [ name: 'POI-DSL-SonarQube', jdk: '1.8', trigger: 'H 9 * * *', maven: true, sonar: true
  64. ],
  65. ]
  66. def svnBase = 'https://svn.apache.org/repos/asf/poi/trunk'
  67. def defaultJdk = '1.6'
  68. def defaultTrigger = 'H/15 * * * *' // check SCM every 60/15 = 4 minutes
  69. def defaultEmail = 'dev@poi.apache.org'
  70. def defaultAnt = 'Ant (latest)'
  71. def defaultSlaves = 'ubuntu&&!cloud-slave'
  72. def jdkMapping = [
  73. '1.6': 'JDK 1.6 (latest)',
  74. '1.7': 'JDK 1.7 (latest)',
  75. '1.8': 'JDK 1.8 (latest)',
  76. '1.9': 'JDK 9 b142 (early access build) with project Jigsaw',
  77. 'OpenJDK': 'OpenJDK 6 (on Ubuntu only) ', // blank is required here until the name in the Jenkins instance is fixed!
  78. 'IBMJDK': 'IBM 1.8 64-bit (on Ubuntu only)',
  79. ]
  80. poijobs.each { poijob ->
  81. def jdkKey = poijob.jdk ?: defaultJdk
  82. def trigger = poijob.trigger ?: defaultTrigger
  83. def email = poijob.email ?: defaultEmail
  84. def slaves = defaultSlaves + (poijob.slaveAdd ?: '')
  85. job(poijob.name) {
  86. if (poijob.disabled) {
  87. disabled()
  88. }
  89. def defaultDesc = '''
  90. <img src="http://poi.apache.org/resources/images/project-logo.jpg" />
  91. <p>
  92. Apache POI - the Java API for Microsoft Documents
  93. </p>
  94. <p>
  95. <b>This is an automatically generated Job Config, do not edit it here!
  96. Instead change the Jenkins Job DSL at <a href="http://svn.apache.org/repos/asf/poi/trunk/jenkins">http://svn.apache.org/repos/asf/poi/trunk/jenkins</a>,
  97. see <a href="https://github.com/jenkinsci/job-dsl-plugin/wiki">https://github.com/jenkinsci/job-dsl-plugin/wiki</a>
  98. for more details about the DSL.</b>
  99. </p>'''
  100. description( defaultDesc +
  101. (poijob.apicheck ?
  102. '''
  103. <p>
  104. <b><a href="https://builds.apache.org/analysis/dashboard?id=org.apache.poi%3Apoi-parent&did=1" target="_blank">Sonar reports</a></b> -
  105. <p>
  106. <b><a href="lastSuccessfulBuild/artifact/build/main/build/reports/japi.html">API Check POI</a></b>
  107. <b><a href="lastSuccessfulBuild/artifact/build/ooxml/build/reports/japi.html">API Check POI-OOXML</a></b>
  108. <b><a href="lastSuccessfulBuild/artifact/build/excelant/build/reports/japi.html">API Check POI-Excelant</a></b>
  109. <b><a href="lastSuccessfulBuild/artifact/build/scratchpad/build/reports/japi.html">API Check POI-Scratchpad</a></b>
  110. </p>
  111. ''' :
  112. '''
  113. <p>
  114. <b><a href="lastSuccessfulBuild/findbugsResult/" target="_blank">Findbugs report of latest build</a></b> -
  115. <b><a href="https://builds.apache.org/analysis/dashboard?id=org.apache.poi%3Apoi-parent&did=1" target="_blank">Sonar reports</a></b> -
  116. <b><a href="lastSuccessfulBuild/artifact/build/coverage/index.html" target="_blank">Coverage of latest build</a></b>
  117. </p>
  118. '''))
  119. logRotator {
  120. numToKeep(5)
  121. artifactNumToKeep(1)
  122. }
  123. label(slaves)
  124. environmentVariables {
  125. env('LANG', 'en_US.UTF-8')
  126. if(jdkKey == '1.9') {
  127. // when using JDK 9 for running Ant, we need to provide more packages for the forbidden-api-checks task
  128. env('ANT_OPTS', '--add-modules=java.xml.bind')
  129. }
  130. }
  131. wrappers {
  132. timeout {
  133. absolute(180)
  134. abortBuild()
  135. writeDescription('Build was aborted due to timeout')
  136. }
  137. if(poijob.sonar) {
  138. configure { project ->
  139. project / buildWrappers << 'hudson.plugins.sonar.SonarBuildWrapper' {}
  140. }
  141. }
  142. }
  143. jdk(jdkMapping.get(jdkKey))
  144. scm {
  145. svn(svnBase) { svnNode ->
  146. svnNode / browser(class: 'hudson.scm.browsers.ViewSVN') /
  147. url << 'http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN'
  148. }
  149. }
  150. triggers {
  151. scm(trigger)
  152. }
  153. def shellcmds = '# show which files are currently modified in the working copy\n' +
  154. 'svn status\n' +
  155. '\n' +
  156. 'echo Java-Home: $JAVA_HOME\n' +
  157. 'ls -al $JAVA_HOME/\n' +
  158. '\n' +
  159. (poijob.shell ?: '') + '\n' +
  160. '# ignore any error message\n' +
  161. 'exit 0\n'
  162. // Create steps and publishers depending on the type of Job that is selected
  163. if(poijob.maven) {
  164. steps {
  165. shell(shellcmds)
  166. maven {
  167. goals('clean')
  168. rootPOM('sonar/pom.xml')
  169. localRepository(LocalRepositoryLocation.LOCAL_TO_WORKSPACE)
  170. mavenInstallation('maven-3.2.1')
  171. }
  172. /* Currently not done, let's see if it is still necessary:
  173. # Maven-Download fails for strange reasons, try to workaround...
  174. 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
  175. */
  176. maven {
  177. if(poijob.sonar) {
  178. goals('compile $SONAR_MAVEN_GOAL -Dsonar.host.url=$SONAR_HOST_URL')
  179. } else {
  180. goals('package')
  181. }
  182. rootPOM('sonar/pom.xml')
  183. mavenOpts('-Xmx2g')
  184. mavenOpts('-Xms256m')
  185. mavenOpts('-XX:MaxPermSize=512m')
  186. mavenOpts('-XX:-OmitStackTraceInFastThrow')
  187. localRepository(LocalRepositoryLocation.LOCAL_TO_WORKSPACE)
  188. mavenInstallation('maven-3.2.1')
  189. }
  190. }
  191. publishers {
  192. if (!poijob.skipcigame) {
  193. configure { project ->
  194. project / publishers << 'hudson.plugins.cigame.GamePublisher' {}
  195. }
  196. }
  197. mailer(email, false, false)
  198. }
  199. } else if (poijob.javadoc) {
  200. steps {
  201. shell(shellcmds)
  202. ant {
  203. targets(['clean', 'javadocs'] + (poijob.properties ?: []))
  204. prop('coverage.enabled', true)
  205. // Properties did not work, so I had to use targets instead
  206. //properties(poijob.properties ?: '')
  207. antInstallation(defaultAnt)
  208. }
  209. shell('zip -r build/javadocs.zip build/tmp/site/build/site/apidocs')
  210. }
  211. publishers {
  212. if (!poijob.skipcigame) {
  213. configure { project ->
  214. project / publishers << 'hudson.plugins.cigame.GamePublisher' {}
  215. }
  216. }
  217. mailer(email, false, false)
  218. }
  219. } else if (poijob.apicheck) {
  220. steps {
  221. shell(shellcmds)
  222. gradle {
  223. tasks('japicmp')
  224. useWrapper(false)
  225. }
  226. }
  227. publishers {
  228. archiveArtifacts('build/*/build/reports/japi.html')
  229. if (!poijob.skipcigame) {
  230. configure { project ->
  231. project / publishers << 'hudson.plugins.cigame.GamePublisher' {}
  232. }
  233. }
  234. mailer(email, false, false)
  235. }
  236. } else {
  237. steps {
  238. shell(shellcmds)
  239. if(poijob.addShell) {
  240. shell(poijob.addShell)
  241. }
  242. // For Jobs that should still have the default set of publishers we can configure different steps here
  243. if(poijob.gradle) {
  244. gradle {
  245. tasks('check')
  246. useWrapper(false)
  247. }
  248. } else if (poijob.noScratchpad) {
  249. ant {
  250. targets(['clean', 'compile-all'] + (poijob.properties ?: []))
  251. prop('coverage.enabled', true)
  252. antInstallation(defaultAnt)
  253. }
  254. ant {
  255. targets(['-Dscratchpad.ignore=true', 'jacocotask', 'test-main', 'test-ooxml', 'test-excelant', 'test-ooxml-lite', 'testcoveragereport'] + (poijob.properties ?: []))
  256. prop('coverage.enabled', true)
  257. antInstallation(defaultAnt)
  258. }
  259. } else {
  260. ant {
  261. targets(['clean', 'jenkins'] + (poijob.properties ?: []))
  262. prop('coverage.enabled', true)
  263. // Properties did not work, so I had to use targets instead
  264. //properties(poijob.properties ?: '')
  265. antInstallation(defaultAnt)
  266. }
  267. ant {
  268. targets(['run'] + (poijob.properties ?: []))
  269. buildFile('src/integrationtest/build.xml')
  270. // Properties did not work, so I had to use targets instead
  271. //properties(poijob.properties ?: '')
  272. antInstallation(defaultAnt)
  273. }
  274. }
  275. }
  276. publishers {
  277. findbugs('build/findbugs.xml', false) {
  278. healthLimits(3, 20)
  279. thresholdLimit('low')
  280. defaultEncoding('UTF-8')
  281. }
  282. // in archive, junit and jacoco publishers, matches beneath build/*/build/... are for Gradle-build results
  283. archiveArtifacts('build/dist/*.tar.gz,build/findbugs.html,build/coverage/**,build/integration-test-results/**,ooxml-lib/**,build/*/build/libs/*.jar')
  284. warnings(['Java Compiler (javac)', 'JavaDoc Tool'], null) {
  285. resolveRelativePaths()
  286. }
  287. 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') {
  288. testDataPublishers {
  289. publishTestStabilityData()
  290. }
  291. }
  292. jacocoCodeCoverage {
  293. classPattern('build/classes,build/excelant-classes,build/ooxml-classes,build/scratchpad-classes,build/*/build/classes')
  294. execPattern('build/*.exec,build/*/build/jacoco/*.exec')
  295. sourcePattern('src/java,src/excelant/java,src/ooxml/java,src/scratchpad/src')
  296. 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')
  297. }
  298. if (!poijob.skipcigame) {
  299. configure { project ->
  300. project / publishers << 'hudson.plugins.cigame.GamePublisher' {}
  301. }
  302. }
  303. mailer(email, false, false)
  304. }
  305. }
  306. }
  307. }