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.

Jenkinsfile 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. node {
  2. // System Dependent Locations
  3. def mvntool = tool name: 'maven3', type: 'hudson.tasks.Maven$MavenInstallation'
  4. def jdktool = tool name: 'jdk8', type: 'hudson.model.JDK'
  5. // Environment
  6. List mvnEnv = ["PATH+MVN=${mvntool}/bin", "PATH+JDK=${jdktool}/bin", "JAVA_HOME=${jdktool}/", "MAVEN_HOME=${mvntool}"]
  7. mvnEnv.add("MAVEN_OPTS=-Xms256m -Xmx1024m -Djava.awt.headless=true")
  8. try
  9. {
  10. stage 'Checkout'
  11. checkout scm
  12. } catch (Exception e) {
  13. //notifyBuild("Checkout Failure")
  14. throw e
  15. }
  16. try
  17. {
  18. stage 'Build'
  19. withEnv(mvnEnv) {
  20. timeout(60) {
  21. // Run test phase / ignore test failures
  22. sh "mvn -B clean install -Dmaven.test.failure.ignore=true"
  23. // Report failures in the jenkins UI
  24. step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml'])
  25. }
  26. if(isUnstable())
  27. {
  28. //notifyBuild("Unstable / Test Errors")
  29. }
  30. }
  31. } catch(Exception e) {
  32. notifyBuild("Test Failure")
  33. throw e
  34. }
  35. }
  36. // Test if the Jenkins Pipeline or Step has marked the
  37. // current build as unstable
  38. def isUnstable()
  39. {
  40. return currentBuild.result == "UNSTABLE"
  41. }
  42. // Send a notification about the build status
  43. def notifyBuild(String buildStatus)
  44. {
  45. // default the value
  46. buildStatus = buildStatus ?: "UNKNOWN"
  47. def email = "${env.EMAILADDRESS}"
  48. def summary = "${env.JOB_NAME}#${env.BUILD_NUMBER} - ${buildStatus}"
  49. def detail = """<h4>Job: <a href='${env.JOB_URL}'>${env.JOB_NAME}</a> [#${env.BUILD_NUMBER}]</h4>
  50. <p><b>${buildStatus}</b></p>
  51. <table>
  52. <tr><td>Build</td><td><a href='${env.BUILD_URL}'>${env.BUILD_URL}</a></td><tr>
  53. <tr><td>Console</td><td><a href='${env.BUILD_URL}console'>${env.BUILD_URL}console</a></td><tr>
  54. <tr><td>Test Report</td><td><a href='${env.BUILD_URL}testReport/'>${env.BUILD_URL}testReport/</a></td><tr>
  55. </table>
  56. """
  57. emailext (
  58. to: email,
  59. subject: summary,
  60. body: detail
  61. )
  62. }
  63. // vim: et:ts=2:sw=2:ft=groovy