Guest User

Untitled

a guest
Jun 19th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. #!groovy
  2. @Library('pa-shared')
  3. import java.lang.Object
  4.  
  5. properties([
  6. [$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', daysToKeepStr: '10', numToKeepStr: '5']]
  7. ])
  8.  
  9. node() {
  10. try {
  11. String buildVersion
  12.  
  13. fallibleStage("Checkout") {
  14. checkout scm
  15. buildVersion = readProjectVersion()
  16. echo "BUILD VERSION DETERMINED AS : ${buildVersion}"
  17. }
  18.  
  19. fallibleStage("Ensure Java Installed") {
  20. env.JAVA_HOME = "${tool 'JDK8'}"
  21. env.PATH = "${env.JAVA_HOME}/bin:${env.PATH}"
  22. sh 'java -version'
  23. }
  24.  
  25. fallibleStage("Stand Up Stack") {
  26. sh "docker ps -q | xargs docker stop 2>/dev/null || true"
  27.  
  28. sh "echo \"ES_JAVA_OPTS=-Xmx750m -Xms750m\" > .env"
  29.  
  30. // terminate any running stack containers, clean and update
  31. sh "docker rm -f selenium-hub || true"
  32.  
  33. //Setup docker hub
  34. sh "docker run -p 4444:4444 --name selenium-hub selenium/hub"
  35. }
  36.  
  37. fallibleStage("Link Selenium Node to Hub") {
  38. //Run chrome node attached to hub
  39. sh "docker run --link selenium-hub:hub selenium/node-chrome"
  40. }
  41.  
  42. fallibleStage("Test") {
  43. mvn "verify"
  44. step([$class: 'CucumberReportPublisher', fileIncludePattern: '**/cucumber-report.json'])
  45. }
  46. }
  47. finally {
  48. notifyResults()
  49. thisRegistry = null // clean this up, as JsonSlurper objects are non-serialisable
  50. cleanWs()
  51. }
  52. }
  53.  
  54. /**
  55. * Maven invocation with build failure on exception.
  56. *
  57. * @param invocation the maven invocation
  58. */
  59. private mvn(String invocation) {
  60. mvn(invocation, true);
  61. }
  62.  
  63. /**
  64. * Maven invocation with build failure on exception.
  65. *
  66. * @param invocation the maven invocation
  67. * @param disableOpenTasksPublisher whether to disable the "Open Tasks" publisher
  68. */
  69. private mvn(String invocation, boolean disableOpenTasksPublisher) {
  70. withMaven(maven: "M3",
  71. options: [openTasksPublisher(disabled: disableOpenTasksPublisher)],
  72. mavenSettingsConfig: "983af180-96cb-4cb3-b252-bbbf858e78ac") {
  73. sh "mvn -B $invocation -Denv.GIT_BRANCH=${env.BRANCH_NAME}"
  74. }
  75. }
Add Comment
Please, Sign In to add comment