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

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