Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. #!groovy
  2.  
  3. /**
  4. * Requires tool definitions for nodejs, jdk, maven, and ant
  5. * Requires config files .npmrc and maven-settings.xml
  6. */
  7. node() {
  8. // checkout clean code
  9. stage("checkout") {
  10. checkout scm
  11. sh "git clean -fdx"
  12. }
  13.  
  14. // setup tools and env
  15. stage("setup" ) {
  16. def nodejs = tool 'nodejs-6.x'
  17. def java = tool 'jdk8'
  18. def maven = tool 'maven-3.3'
  19. def ant = tool 'ant-1.9'
  20. env.JAVA_HOME = "${java}"
  21. env.PATH="${java}/bin:${maven}/bin:${ant}/bin:${nodejs}/bin:${env.PATH}"
  22. configFileProvider([configFile(fileId: '.npmrc', targetLocation: '.npmrc')]) {}
  23. }
  24.  
  25. dir("app") {
  26. // install dependencies
  27. stage("install" ) {
  28. sh "npm install"
  29. }
  30.  
  31. // run tests
  32. stage("test" ) {
  33. def container;
  34.  
  35. try {
  36. container = docker.image('postgres').run("-P -e POSTGRES_PASSWORD=changeit")
  37. def port = container.port(5432).split(":")[1];
  38. // container takes a few seconds to start up
  39. retry(5) {
  40. sleep 1
  41. sh "db__port=${port} NODE_ENV=test npm run migrate"
  42. }
  43. sh "db__port=${port} npm test"
  44. } finally {
  45. if (container) {
  46. container.stop();
  47. }
  48. }
  49. }
  50.  
  51. // package code
  52. stage("package") {
  53. sh "npm run archive"
  54. }
  55. }
  56. dir("installer") {
  57.  
  58. // build installer part
  59. stage("build installer") {
  60. configFileProvider([configFile(fileId: 'maven-settings.xml', variable: "MAVEN_SETTINGS")]) {
  61. sh "mvn -s ${MAVEN_SETTINGS} install"
  62. }
  63. }
  64.  
  65. stage("archive") {
  66. archiveArtifacts artifacts: "target/**/*.zip,target/**/*.md5"
  67. }
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement