Jenkinsfile 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. deleteDir()
  10. checkout scm
  11. }
  12. stage('Stop Containers') {
  13. sh 'docker ps | grep "workflow_" -v | awk -F " " \'{ if(NR>1) print $1}\' |xargs docker kill |xargs docker rm || true'
  14. sh 'docker system prune -f'
  15. }
  16. stage("Push ${e} images to nexus") {
  17. withCredentials([usernamePassword(credentialsId: 'nexus', usernameVariable: 'NEXUS_USERNAME', passwordVariable: 'NEXUS_PASSWORD')]) {
  18. def nexusUrl = 'https://nexus.foodgame.fr'
  19. def nexusRepository = 'fatboar_repo'
  20. docker.withRegistry("${nexusUrl}", 'nexus') {
  21. // Push des images Docker vers le registre Nexus
  22. sh "docker push ${nexusUrl}/repository/${nexusRepository}/workflow_jenkins_1:latest"
  23. }
  24. }
  25. }
  26. stage('Build Docker MEAN Stack(PreProduction Deployment)') {
  27. sh 'docker-compose -v'
  28. sh 'docker-compose stop'
  29. sh 'docker-compose build'
  30. sh 'docker-compose up -d'
  31. }
  32. stage('Fin du Pipeline') {
  33. sh 'echo "Félicitation tout s\'est bien déroulé!"'
  34. }
  35. }