Jenkinsfile 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. node{
  2. env.NODEJS_HOME = "${tool 'NodeJS'}"
  3. // on linux / mac
  4. env.PATH="${env.NODEJS_HOME}/bin:${env.PATH}"
  5. // on windows
  6. //env.PATH="${env.NODEJS_HOME};${env.PATH}"
  7. sh 'npm --version'
  8. stage('checkout')
  9. {
  10. deleteDir()
  11. checkout scm
  12. }
  13. stage('Stop Containers')
  14. {
  15. sh 'docker ps | grep "workflow_" -v | awk -F " " \'{ if(NR>1) print $1}\' |xargs docker kill |xargs docker rm || true'
  16. sh 'docker system prune -f'
  17. }
  18. def imageApache = stage("Build apache dev")
  19. {
  20. docker.build("server-apache-dev", "--no-cache --label traefik.enable=true --label traefik.http.routers.server-apache-dev.rule='Host(`angular-dev.foodgame.fr`)' --label traefik.http.routers.server-apache-dev.entrypoints=websecure --label traefik.http.routers.server-apache-dev.tls.certresolver=myresolver -f build/docker/httpd/Dockerfile .")
  21. }
  22. def imageExpress = stage("Build express dev")
  23. {
  24. docker.build("server-express-dev", "--no-cache -f express-server/Dockerfile express-server")
  25. }
  26. // stage("Push preprod images to nexus")
  27. // {
  28. // docker.withRegistry('http://localhost:8083','885ef60c-9352-489a-bd1c-e4b695747c21')
  29. // {
  30. // imageApache.push('latest')
  31. // imageExpress.push('latest')
  32. // }
  33. // }
  34. // stage('SonarQube analysis')
  35. // {
  36. // def scannerHome = tool name: 'SonarQube Scanner', type: 'hudson.plugins.sonar.SonarRunnerInstallation';
  37. // withSonarQubeEnv('SonarQube')
  38. // {
  39. // // If you have configured more than one global server connection, you can specify its name
  40. // sh "${scannerHome}/bin/sonar-scanner \
  41. // -Dsonar.projectKey=FatboarProject \
  42. // -Dsonar.sources=. \
  43. // -Dsonar.host.url=https://sonarqube.foodgame.fr \
  44. // -Dsonar.login=sqa_9980d9f6eac6a910947f1b55aaa280c93f02236b"
  45. // }
  46. // }
  47. stage('Build Docker MEAN Stack(PreProduction Deployment)')
  48. {
  49. sh 'docker-compose -v'
  50. sh 'docker-compose stop'
  51. sh 'docker-compose build'
  52. sh 'docker-compose up -d'
  53. }
  54. stage('Fin du Pipeline')
  55. {
  56. sh 'echo "Félicitation tout s\'est bien déroulé!"'
  57. }
  58. }