From 4f60d3e7df3d84b9d2aef567ecf82013339190f6 Mon Sep 17 00:00:00 2001 From: Jamie Curnow Date: Mon, 18 Feb 2019 21:14:26 +1000 Subject: [PATCH] Fix CI now that tags are changes --- Jenkinsfile | 134 ++++++++++++++++++++++++++-------------------------- 1 file changed, 67 insertions(+), 67 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index aa2d4967..be237f9e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,13 +5,13 @@ pipeline { } agent any environment { - IMAGE_NAME = "nginx-proxy-manager" - BASE_IMAGE_NAME = "jc21/nginx-proxy-manager-base:latest" - TEMP_IMAGE_NAME = "nginx-proxy-manager-build_${BUILD_NUMBER}" - TEMP_IMAGE_NAME_ARM = "nginx-proxy-manager-arm-build_${BUILD_NUMBER}" - TEMP_IMAGE_NAME_ARM64 = "nginx-proxy-manager-arm64-build_${BUILD_NUMBER}" - TAG_VERSION = getPackageVersion() - MAJOR_VERSION = "2" + IMAGE = "nginx-proxy-manager" + BASE_IMAGE = "jc21/nginx-proxy-manager-base" + TEMP_IMAGE = "nginx-proxy-manager-build_${BUILD_NUMBER}" + TEMP_IMAGE_ARM = "nginx-proxy-manager-arm-build_${BUILD_NUMBER}" + TEMP_IMAGE_ARM64 = "nginx-proxy-manager-arm64-build_${BUILD_NUMBER}" + TAG_VERSION = getPackageVersion() + MAJOR_VERSION = "2" } stages { stage('Prepare') { @@ -26,30 +26,30 @@ pipeline { steps { ansiColor('xterm') { // Codebase - sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE_NAME yarn install' - sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE_NAME npm run-script build' + sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE yarn install' + sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE npm run-script build' sh 'rm -rf node_modules' - sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE_NAME yarn install --prod' + sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE yarn install --prod' sh 'docker run --rm -v $(pwd):/data $DOCKER_CI_TOOLS node-prune' // Docker Build - sh 'docker build --pull --no-cache --squash --compress -t $TEMP_IMAGE_NAME .' + sh 'docker build --pull --no-cache --squash --compress -t $TEMP_IMAGE .' // Dockerhub - sh 'docker tag $TEMP_IMAGE_NAME docker.io/jc21/$IMAGE_NAME:develop' + sh 'docker tag $TEMP_IMAGE docker.io/jc21/$IMAGE:develop' withCredentials([usernamePassword(credentialsId: 'jc21-dockerhub', passwordVariable: 'dpass', usernameVariable: 'duser')]) { sh "docker login -u '${duser}' -p '$dpass'" - sh 'docker push docker.io/jc21/$IMAGE_NAME:develop' + sh 'docker push docker.io/jc21/$IMAGE:develop' } // Private Registry - sh 'docker tag $TEMP_IMAGE_NAME $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:develop' + sh 'docker tag $TEMP_IMAGE $DOCKER_PRIVATE_REGISTRY/$IMAGE:develop' withCredentials([usernamePassword(credentialsId: 'jc21-private-registry', passwordVariable: 'dpass', usernameVariable: 'duser')]) { sh "docker login -u '${duser}' -p '$dpass' $DOCKER_PRIVATE_REGISTRY" - sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:develop' + sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE:develop' } - sh 'docker rmi $TEMP_IMAGE_NAME' + sh 'docker rmi $TEMP_IMAGE' } } } @@ -62,40 +62,40 @@ pipeline { steps { ansiColor('xterm') { // Codebase - sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE_NAME yarn install' - sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE_NAME npm run-script build' + sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE yarn install' + sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE npm run-script build' sh 'rm -rf node_modules' - sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE_NAME yarn install --prod' + sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE yarn install --prod' sh 'docker run --rm -v $(pwd):/data $DOCKER_CI_TOOLS node-prune' // Docker Build - sh 'docker build --pull --no-cache --squash --compress -t $TEMP_IMAGE_NAME .' + sh 'docker build --pull --no-cache --squash --compress -t $TEMP_IMAGE .' // Dockerhub - sh 'docker tag $TEMP_IMAGE_NAME docker.io/jc21/$IMAGE_NAME:$TAG_VERSION' - sh 'docker tag $TEMP_IMAGE_NAME docker.io/jc21/$IMAGE_NAME:$MAJOR_VERSION' - sh 'docker tag $TEMP_IMAGE_NAME docker.io/jc21/$IMAGE_NAME:latest' + sh 'docker tag $TEMP_IMAGE docker.io/jc21/$IMAGE:$TAG_VERSION' + sh 'docker tag $TEMP_IMAGE docker.io/jc21/$IMAGE:$MAJOR_VERSION' + sh 'docker tag $TEMP_IMAGE docker.io/jc21/$IMAGE:latest' withCredentials([usernamePassword(credentialsId: 'jc21-dockerhub', passwordVariable: 'dpass', usernameVariable: 'duser')]) { sh "docker login -u '${duser}' -p '$dpass'" - sh 'docker push docker.io/jc21/$IMAGE_NAME:$TAG_VERSION' - sh 'docker push docker.io/jc21/$IMAGE_NAME:$MAJOR_VERSION' - sh 'docker push docker.io/jc21/$IMAGE_NAME:latest' + sh 'docker push docker.io/jc21/$IMAGE:$TAG_VERSION' + sh 'docker push docker.io/jc21/$IMAGE:$MAJOR_VERSION' + sh 'docker push docker.io/jc21/$IMAGE:latest' } // Private Registry - sh 'docker tag $TEMP_IMAGE_NAME $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:$TAG_VERSION' - sh 'docker tag $TEMP_IMAGE_NAME $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:$MAJOR_VERSION' - sh 'docker tag $TEMP_IMAGE_NAME $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:latest' + sh 'docker tag $TEMP_IMAGE $DOCKER_PRIVATE_REGISTRY/$IMAGE:$TAG_VERSION' + sh 'docker tag $TEMP_IMAGE $DOCKER_PRIVATE_REGISTRY/$IMAGE:$MAJOR_VERSION' + sh 'docker tag $TEMP_IMAGE $DOCKER_PRIVATE_REGISTRY/$IMAGE:latest' withCredentials([usernamePassword(credentialsId: 'jc21-private-registry', passwordVariable: 'dpass', usernameVariable: 'duser')]) { sh "docker login -u '${duser}' -p '$dpass' $DOCKER_PRIVATE_REGISTRY" - sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:$TAG_VERSION' - sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:$MAJOR_VERSION' - sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:latest' + sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE:$TAG_VERSION' + sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE:$MAJOR_VERSION' + sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE:latest' } - sh 'docker rmi $TEMP_IMAGE_NAME' + sh 'docker rmi $TEMP_IMAGE' } } } @@ -109,39 +109,39 @@ pipeline { steps { ansiColor('xterm') { // Codebase - sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE_NAME-armhf yarn install' - sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE_NAME-armhf npm run-script build' + sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE:armhf yarn install' + sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE:armhf npm run-script build' sh 'rm -rf node_modules' - sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE_NAME-armhf yarn install --prod' + sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE:armhf yarn install --prod' // Docker Build - sh 'docker build --pull --no-cache --squash --compress -t $TEMP_IMAGE_NAME_ARM -f Dockerfile.armhf .' + sh 'docker build --pull --no-cache --squash --compress -t $TEMP_IMAGE_ARM -f Dockerfile.armhf .' // Dockerhub - sh 'docker tag $TEMP_IMAGE_NAME_ARM docker.io/jc21/$IMAGE_NAME:$TAG_VERSION-armhf' - sh 'docker tag $TEMP_IMAGE_NAME_ARM docker.io/jc21/$IMAGE_NAME:$MAJOR_VERSION-armhf' - sh 'docker tag $TEMP_IMAGE_NAME_ARM docker.io/jc21/$IMAGE_NAME:latest-armhf' + sh 'docker tag $TEMP_IMAGE_ARM docker.io/jc21/$IMAGE:$TAG_VERSION-armhf' + sh 'docker tag $TEMP_IMAGE_ARM docker.io/jc21/$IMAGE:$MAJOR_VERSION-armhf' + sh 'docker tag $TEMP_IMAGE_ARM docker.io/jc21/$IMAGE:latest-armhf' withCredentials([usernamePassword(credentialsId: 'jc21-dockerhub', passwordVariable: 'dpass', usernameVariable: 'duser')]) { sh "docker login -u '${duser}' -p '$dpass'" - sh 'docker push docker.io/jc21/$IMAGE_NAME:$TAG_VERSION-armhf' - sh 'docker push docker.io/jc21/$IMAGE_NAME:$MAJOR_VERSION-armhf' - sh 'docker push docker.io/jc21/$IMAGE_NAME:latest-armhf' + sh 'docker push docker.io/jc21/$IMAGE:$TAG_VERSION-armhf' + sh 'docker push docker.io/jc21/$IMAGE:$MAJOR_VERSION-armhf' + sh 'docker push docker.io/jc21/$IMAGE:latest-armhf' } // Private Registry - sh 'docker tag $TEMP_IMAGE_NAME_ARM $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:$TAG_VERSION-armhf' - sh 'docker tag $TEMP_IMAGE_NAME_ARM $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:$MAJOR_VERSION-armhf' - sh 'docker tag $TEMP_IMAGE_NAME_ARM $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:latest-armhf' + sh 'docker tag $TEMP_IMAGE_ARM $DOCKER_PRIVATE_REGISTRY/$IMAGE:$TAG_VERSION-armhf' + sh 'docker tag $TEMP_IMAGE_ARM $DOCKER_PRIVATE_REGISTRY/$IMAGE:$MAJOR_VERSION-armhf' + sh 'docker tag $TEMP_IMAGE_ARM $DOCKER_PRIVATE_REGISTRY/$IMAGE:latest-armhf' withCredentials([usernamePassword(credentialsId: 'jc21-private-registry', passwordVariable: 'dpass', usernameVariable: 'duser')]) { sh "docker login -u '${duser}' -p '$dpass' $DOCKER_PRIVATE_REGISTRY" - sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:$TAG_VERSION-armhf' - sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:$MAJOR_VERSION-armhf' - sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:latest-armhf' + sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE:$TAG_VERSION-armhf' + sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE:$MAJOR_VERSION-armhf' + sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE:latest-armhf' } - sh 'docker rmi $TEMP_IMAGE_NAME_ARM' + sh 'docker rmi $TEMP_IMAGE_ARM' } } } @@ -155,39 +155,39 @@ pipeline { steps { ansiColor('xterm') { // Codebase - sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE_NAME-arm64 yarn install' - sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE_NAME-arm64 npm run-script build' + sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE:arm64 yarn install' + sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE:arm64 npm run-script build' sh 'rm -rf node_modules' - sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE_NAME-arm64 yarn install --prod' + sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE:arm64 yarn install --prod' // Docker Build - sh 'docker build --pull --no-cache --squash --compress -t $TEMP_IMAGE_NAME_ARM64 -f Dockerfile.arm64 .' + sh 'docker build --pull --no-cache --squash --compress -t $TEMP_IMAGE_ARM64 -f Dockerfile.arm64 .' // Dockerhub - sh 'docker tag $TEMP_IMAGE_NAME_ARM64 docker.io/jc21/$IMAGE_NAME:$TAG_VERSION-arm64' - sh 'docker tag $TEMP_IMAGE_NAME_ARM64 docker.io/jc21/$IMAGE_NAME:$MAJOR_VERSION-arm64' - sh 'docker tag $TEMP_IMAGE_NAME_ARM64 docker.io/jc21/$IMAGE_NAME:latest-arm64' + sh 'docker tag $TEMP_IMAGE_ARM64 docker.io/jc21/$IMAGE:$TAG_VERSION-arm64' + sh 'docker tag $TEMP_IMAGE_ARM64 docker.io/jc21/$IMAGE:$MAJOR_VERSION-arm64' + sh 'docker tag $TEMP_IMAGE_ARM64 docker.io/jc21/$IMAGE:latest-arm64' withCredentials([usernamePassword(credentialsId: 'jc21-dockerhub', passwordVariable: 'dpass', usernameVariable: 'duser')]) { sh "docker login -u '${duser}' -p '$dpass'" - sh 'docker push docker.io/jc21/$IMAGE_NAME:$TAG_VERSION-arm64' - sh 'docker push docker.io/jc21/$IMAGE_NAME:$MAJOR_VERSION-arm64' - sh 'docker push docker.io/jc21/$IMAGE_NAME:latest-arm64' + sh 'docker push docker.io/jc21/$IMAGE:$TAG_VERSION-arm64' + sh 'docker push docker.io/jc21/$IMAGE:$MAJOR_VERSION-arm64' + sh 'docker push docker.io/jc21/$IMAGE:latest-arm64' } // Private Registry - sh 'docker tag $TEMP_IMAGE_NAME_ARM64 $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:$TAG_VERSION-arm64' - sh 'docker tag $TEMP_IMAGE_NAME_ARM64 $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:$MAJOR_VERSION-arm64' - sh 'docker tag $TEMP_IMAGE_NAME_ARM64 $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:latest-arm64' + sh 'docker tag $TEMP_IMAGE_ARM64 $DOCKER_PRIVATE_REGISTRY/$IMAGE:$TAG_VERSION-arm64' + sh 'docker tag $TEMP_IMAGE_ARM64 $DOCKER_PRIVATE_REGISTRY/$IMAGE:$MAJOR_VERSION-arm64' + sh 'docker tag $TEMP_IMAGE_ARM64 $DOCKER_PRIVATE_REGISTRY/$IMAGE:latest-arm64' withCredentials([usernamePassword(credentialsId: 'jc21-private-registry', passwordVariable: 'dpass', usernameVariable: 'duser')]) { sh "docker login -u '${duser}' -p '$dpass' $DOCKER_PRIVATE_REGISTRY" - sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:$TAG_VERSION-arm64' - sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:$MAJOR_VERSION-arm64' - sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME:latest-arm64' + sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE:$TAG_VERSION-arm64' + sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE:$MAJOR_VERSION-arm64' + sh 'docker push $DOCKER_PRIVATE_REGISTRY/$IMAGE:latest-arm64' } - sh 'docker rmi $TEMP_IMAGE_NAME_ARM64' + sh 'docker rmi $TEMP_IMAGE_ARM64' } } }