Jenkinsfile 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. node("ubuntu") {
  19. docker.image('elek/ozone-build').pull()
  20. docker.image('elek/ozone-build').inside {
  21. stage('Checkout') {
  22. checkout scm
  23. }
  24. stage('Clean') {
  25. status = sh returnStatus: true, script: 'mvn clean'
  26. }
  27. stageRunner('Author', "author", {})
  28. stageRunner('Isolation', "isolation", {})
  29. stageRunner('Build', "build", {})
  30. stageRunner('Licence', "rat", {
  31. archiveArtifacts 'target/rat-aggregated.txt'
  32. }, 'artifact/target/rat-aggregated.txt/*view*/')
  33. stageRunner('Unit test', "unit", {
  34. junit '**/target/surefire-reports/*.xml'
  35. }, 'testReport/')
  36. stageRunner('Findbugs', "findbugs", {
  37. archiveArtifacts 'target/findbugs-all.txt'
  38. }, 'artifact/target/findbugs-all.txt/*view*/')
  39. stageRunner('Checkstyle', "checkstyle", {
  40. checkstyle canComputeNew: false, canRunOnFailed: true, defaultEncoding: '', healthy: '', pattern: '**/checkstyle-result.xml', unHealthy: ''
  41. }, 'checkstyleResult')
  42. }
  43. }
  44. def stageRunner(name, type, processResult, url = '') {
  45. try {
  46. stage(name) {
  47. prStatusStart(type)
  48. status = sh returnStatus: true, script: 'hadoop-ozone/dev-support/checks/' + type + '.sh'
  49. processResult()
  50. prStatusResult(status, type, url)
  51. }
  52. return true
  53. } catch (RuntimeException ex) {
  54. currentBuild.result = "FAILED"
  55. return false
  56. }
  57. }
  58. def prStatusStart(name) {
  59. if (env.CHANGE_ID) {
  60. pullRequest.createStatus(status: "pending",
  61. context: 'continuous-integration/jenkins/pr-merge/' + name,
  62. description: name + " is started")
  63. }
  64. }
  65. def prStatusResult(responseCode, name, url = '') {
  66. status = "error"
  67. desc = "failed"
  68. if (responseCode == 0) {
  69. status = "success"
  70. desc = "passed"
  71. }
  72. message = name + " is " + desc
  73. //System.out.println(responseCode)
  74. if (env.CHANGE_ID) {
  75. if (url) {
  76. pullRequest.createStatus(status: status,
  77. context: 'continuous-integration/jenkins/pr-merge/' + name,
  78. description: message,
  79. targetUrl: env.BUILD_URL + url)
  80. } else {
  81. pullRequest.createStatus(status: status,
  82. context: 'continuous-integration/jenkins/pr-merge/' + name,
  83. description: message)
  84. }
  85. }
  86. if (responseCode != 0) {
  87. throw new RuntimeException(message)
  88. }
  89. }