← azuredeploy

Push secondary image also, authenticate once

82d8ab7ab27f0871f212f57ab1a063f0923c9436 · ovidiucs · Mar 22, 2024 17:56

+11 −12 · 1 file changed

  • jenkins/Jenkinsfile +11 −12
diff --git a/jenkins/Jenkinsfile b/jenkins/Jenkinsfile
index e3db5e9..d138c79 100644
--- a/jenkins/Jenkinsfile
+++ b/jenkins/Jenkinsfile
@@ -2,18 +2,17 @@ pipeline {
     agent any
     
     environment {
-            DOCKER_IMAGE_NAME = 'primary_container'
-            DOCKER_IMAGE_NAME_SECONDARY = 'secondary_container'
-            DOCKERFILE_PATH = 'codefiles/src/Dockerfile.primary'
-            DOCKERFILE_PATH_SECONDARY = 'codefiles/src/Dockerfile.secondary'
+        DOCKER_IMAGE_NAME = 'primary_container'
+        DOCKER_IMAGE_NAME_SECONDARY = 'secondary_container'
+        DOCKERFILE_PATH = 'codefiles/src/Dockerfile.primary'
+        DOCKERFILE_PATH_SECONDARY = 'codefiles/src/Dockerfile.secondary'
     }
     
     triggers {
-        pollSCM('H/5 * * * *') // Poll every five minutes as an example
+        pollSCM('H/5 * * * *')
     }
     
     stages {
-    
         stage('Checkout') {
             steps {
                 checkout scm
@@ -49,14 +48,15 @@ pipeline {
                 }
             }
         }
-        stage('Push Docker Image') {
+        stage('Push Docker Images') {
             steps {
                 script {
-                    // Retrieve Docker registry URL from Jenkins secret text
                     def dockerRegistryUrl = env.DOCKER_REGISTRY_URL
                     docker.withRegistry(dockerRegistryUrl, 'myACRCredentials') {
-                    // Push Docker image to registry
-                    docker.image(DOCKER_IMAGE_NAME).push('latest')
+                        // Push Primary Docker image to registry
+                        docker.image(env.DOCKER_IMAGE_NAME).push('latest')
+                        // If you need to push the secondary image, uncomment the following line:
+                        // docker.image(env.DOCKER_IMAGE_NAME_SECONDARY).push('latest')
                     }
                 }
             }
@@ -73,8 +73,6 @@ pipeline {
                 sh 'echo test'
             }
         }
-        
-        // Add more stages as needed
     }
     
     post {
@@ -86,3 +84,4 @@ pipeline {
         }
     }
 }
+