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

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