From 08fe46311dc0208eba498f5025d9808a2d513f1b Mon Sep 17 00:00:00 2001 From: Jamie Curnow Date: Wed, 20 Jun 2018 10:31:10 +1000 Subject: [PATCH] Updated CI --- Jenkinsfile | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 24a1afe..d731bba 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,10 +11,10 @@ pipeline { } stages { stage('Prepare') { - steps { - sh 'docker pull jc21/$IMAGE_NAME-base' - sh 'docker pull jc21/node' - sh 'docker pull $DOCKER_CI_TOOLS' + steps { + sh 'docker pull jc21/$IMAGE_NAME-base' + sh 'docker pull jc21/node' + sh 'docker pull $DOCKER_CI_TOOLS' } } stage('Build') { @@ -27,20 +27,24 @@ pipeline { sh 'docker build --squash --compress -t $TEMP_IMAGE_NAME .' } } - stage('Publish') { + stage('Publish Private') { + steps { + sh 'docker tag $TEMP_IMAGE_NAME ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:$TAG_VERSION' + sh 'docker push ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:$TAG_VERSION' + } + } + stage('Publish Public') { when { branch 'master' } steps { sh 'docker tag $TEMP_IMAGE_NAME ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:latest' sh 'docker push ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:latest' - sh 'docker tag $TEMP_IMAGE_NAME ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:$TAG_VERSION' - sh 'docker push ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:$TAG_VERSION' sh 'docker tag $TEMP_IMAGE_NAME docker.io/jc21/$IMAGE_NAME:latest' sh 'docker tag $TEMP_IMAGE_NAME docker.io/jc21/$IMAGE_NAME:$TAG_VERSION' withCredentials([usernamePassword(credentialsId: 'jc21-dockerhub', passwordVariable: 'dpass', usernameVariable: 'duser')]) { - sh "docker login -u '${duser}' -p '$dpass'" + sh "docker login -u '${duser}' -p '${dpass}'" sh 'docker push docker.io/jc21/$IMAGE_NAME:latest' sh 'docker push docker.io/jc21/$IMAGE_NAME:$TAG_VERSION' }