formation 1 год назад
Родитель
Сommit
d133773996
1 измененных файлов с 11 добавлено и 15 удалено
  1. 11 15
      Jenkinsfile

+ 11 - 15
Jenkinsfile

@@ -17,23 +17,19 @@ node {
     }
     }
 
 
 
 
-    stage('Build and Push Docker Image') {
-        withCredentials([usernamePassword(credentialsId: 'nexus', usernameVariable: 'NEXUS_USERNAME', passwordVariable: 'NEXUS_PASSWORD')]) {
-            def dockerImageName = 'workflow_jenkins_1'
-            def dockerImageTag = 'latest'
-            def nexusUrl = 'https://nexus.foodgame.fr'
-            def nexusRepository = 'fatboar_repo'
-
-            // Connexion au registre Docker Nexus
-            sh "docker login -u ${NEXUS_USERNAME} -p ${NEXUS_PASSWORD} ${nexusUrl}"
-
-            // Balisage de l'image Docker pour le registre Nexus
-            sh "docker tag ${dockerImageName}:${dockerImageTag} ${nexusUrl}/repository/${nexusRepository}/${dockerImageName}:${dockerImageTag}"
-
-            // Poussée de l'image Docker vers le registre Nexus
-            sh "docker push ${nexusUrl}/repository/${nexusRepository}/${dockerImageName}:${dockerImageTag}"
+   stage("Push ${e} images to nexus") {
+    withCredentials([usernamePassword(credentialsId: 'nexus', usernameVariable: 'NEXUS_USERNAME', passwordVariable: 'NEXUS_PASSWORD')]) {
+        def nexusUrl = 'https://nexus.foodgame.fr'
+        def nexusRepository = 'fatboar_repo'
+        
+        docker.withRegistry("${nexusUrl}", 'nexus') {
+            // Push des images Docker vers le registre Nexus
+            sh "docker push ${nexusUrl}/repository/${nexusRepository}/workflow_jenkins_1:latest"
+            
         }
         }
     }
     }
+}
+
     
     
 
 
     stage('Build Docker MEAN Stack(PreProduction Deployment)') {
     stage('Build Docker MEAN Stack(PreProduction Deployment)') {