Push secondary image also, authenticate once
+11 −12 · 1 file changed
-
jenkins/Jenkinsfile+11 −12
@@ -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 { } } } +