Jenkinsfile 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. // stage("Push preprod images to nexus")
  19. // {
  20. // docker.withRegistry('http://localhost:8083','885ef60c-9352-489a-bd1c-e4b695747c21')
  21. // {
  22. // imageApache.push('latest')
  23. // imageExpress.push('latest')
  24. // }
  25. // }
  26. stage('SonarQube analysis')
  27. {
  28. def scannerHome = tool name: 'SonarQube Scanner', type: 'hudson.plugins.sonar.SonarRunnerInstallation';
  29. withSonarQubeEnv('SonarQube')
  30. {
  31. // If you have configured more than one global server connection, you can specify its name
  32. sh "${scannerHome}/bin/sonar-scanner \
  33. -Dsonar.projectKey=FatboarProject \
  34. -Dsonar.sources=. \
  35. -Dsonar.host.url=https://sonarqube.foodgame.fr \
  36. -Dsonar.login=sqa_9980d9f6eac6a910947f1b55aaa280c93f02236b"
  37. }
  38. }
  39. stage('Build Docker MEAN Stack(PreProduction Deployment)')
  40. {
  41. sh 'docker-compose -v'
  42. sh 'docker-compose stop'
  43. sh 'docker-compose build'
  44. sh 'docker-compose up -d'
  45. }
  46. stage('Fin du Pipeline')
  47. {
  48. sh 'echo "Félicitation tout s\'est bien déroulé!"'
  49. }
  50. }