Jenkinsfile 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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('Push Docker images to Nexus') {
  27. withCredentials([usernamePassword(credentialsId: 'nexus', usernameVariable: 'admin', passwordVariable: 'azerty10')]) {
  28. sh "docker login -u ${admin} -p ${azerty10} nexus.foodgame.fr:8443"
  29. sh "docker-compose push"
  30. }
  31. }
  32. stage('Build Docker MEAN Stack(PreProduction Deployment)')
  33. {
  34. sh 'docker-compose -v'
  35. sh 'docker-compose stop'
  36. sh 'docker-compose build'
  37. sh 'docker-compose up -d'
  38. }
  39. stage('Fin du Pipeline')
  40. {
  41. sh 'echo "Félicitation tout s\'est bien déroulé!"'
  42. }
  43. }