From f1c86a7d497e9a4f9bf5f8d328a85116edd45c08 Mon Sep 17 00:00:00 2001 From: Jamie Curnow Date: Thu, 3 May 2018 23:46:03 +1000 Subject: [PATCH] Fix CI pipeline --- Jenkinsfile | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a2afda02..6ae895fa 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -39,27 +39,27 @@ node-prune''' } stage('Build') { steps { - sh '''docker build -t $TEMP_IMAGE_NAME . -exit $?''' + sh 'docker build -t $TEMP_IMAGE_NAME .' } } stage('Publish') { + when { + branch 'master' + } steps { - sh '''docker tag $TEMP_IMAGE_NAME ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:latest -docker push ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:latest -exit $?''' + 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' - sh '''docker tag $TEMP_IMAGE_NAME ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:$TAG_VERSION -docker push ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:$TAG_VERSION -exit $?''' + withDockerRegistry([credentialsId: 'jc21-dockerhub', url: '']) { + sh 'docker push docker-io/jc21/$IMAGE_NAME:latest' + sh 'docker push docker-io/jc21/$IMAGE_NAME:$TAG_VERSION' + } - sh '''docker tag $TEMP_IMAGE_NAME docker-io/jc21/$IMAGE_NAME:latest -docker push docker-io/jc21/$IMAGE_NAME:latest -exit $?''' - - sh '''docker tag $TEMP_IMAGE_NAME docker-io/jc21/$IMAGE_NAME:$TAG_VERSION -docker push docker-io/jc21/$IMAGE_NAME:$TAG_VERSION -exit $?''' + sh 'docker rmi $TEMP_IMAGE_NAME' } } }