nginx-proxy-manager/Jenkinsfile

214 lines
9.5 KiB
Plaintext
Raw Normal View History

2018-05-03 05:43:04 +00:00
pipeline {
options {
2018-07-29 09:09:40 +00:00
buildDiscarder(logRotator(numToKeepStr: '10'))
2018-05-03 05:43:04 +00:00
disableConcurrentBuilds()
}
agent any
environment {
2019-02-18 11:12:41 +00:00
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"
2018-05-03 06:07:34 +00:00
}
2018-05-03 05:43:04 +00:00
stages {
stage('Prepare') {
2018-06-20 00:31:10 +00:00
steps {
sh 'docker pull $DOCKER_CI_TOOLS'
2018-05-03 05:43:04 +00:00
}
}
2018-11-12 11:48:12 +00:00
stage('Build Develop') {
when {
branch 'develop'
}
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 '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):/data $DOCKER_CI_TOOLS node-prune'
// Docker Build
sh 'docker build --pull --no-cache --squash --compress -t $TEMP_IMAGE_NAME .'
// Dockerhub
sh 'docker tag $TEMP_IMAGE_NAME docker.io/jc21/$IMAGE_NAME: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'
}
2018-12-13 02:20:41 +00:00
// Private Registry
sh 'docker tag $TEMP_IMAGE_NAME $DOCKER_PRIVATE_REGISTRY/$IMAGE_NAME: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'
}
2018-11-12 11:48:12 +00:00
sh 'docker rmi $TEMP_IMAGE_NAME'
}
}
}
stage('Build Master') {
2018-07-29 09:09:40 +00:00
parallel {
stage('x86_64') {
when {
branch 'master'
}
steps {
2018-07-30 23:09:20 +00:00
ansiColor('xterm') {
// Codebase
2018-10-25 00:53:45 +00:00
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'
2018-07-30 23:09:20 +00:00
sh 'rm -rf node_modules'
2018-10-25 00:53:45 +00:00
sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE_NAME yarn install --prod'
2018-07-30 06:47:28 +00:00
sh 'docker run --rm -v $(pwd):/data $DOCKER_CI_TOOLS node-prune'
2018-07-29 09:09:40 +00:00
2018-07-30 23:09:20 +00:00
// Docker Build
sh 'docker build --pull --no-cache --squash --compress -t $TEMP_IMAGE_NAME .'
2018-07-29 09:09:40 +00:00
2018-07-30 23:09:20 +00:00
// Dockerhub
sh 'docker tag $TEMP_IMAGE_NAME docker.io/jc21/$IMAGE_NAME:$TAG_VERSION'
2018-08-24 11:29:31 +00:00
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'
2018-07-29 09:09:40 +00:00
2018-07-30 23:09:20 +00:00
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'
2018-08-24 11:29:31 +00:00
sh 'docker push docker.io/jc21/$IMAGE_NAME:$MAJOR_VERSION'
sh 'docker push docker.io/jc21/$IMAGE_NAME:latest'
2018-07-30 23:09:20 +00:00
}
2018-05-03 05:43:04 +00:00
2018-12-13 02:20:41 +00:00
// 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'
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'
}
2018-07-30 23:09:20 +00:00
sh 'docker rmi $TEMP_IMAGE_NAME'
}
2018-07-29 09:09:40 +00:00
}
}
stage('armhf') {
when {
branch 'master'
}
agent {
label 'armhf'
}
steps {
2018-07-30 23:09:20 +00:00
ansiColor('xterm') {
// Codebase
2018-10-25 00:53:45 +00:00
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'
2018-07-30 06:47:28 +00:00
sh 'rm -rf node_modules'
2018-10-25 00:53:45 +00:00
sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE_NAME-armhf yarn install --prod'
2018-07-29 09:09:40 +00:00
2018-07-30 23:09:20 +00:00
// Docker Build
sh 'docker build --pull --no-cache --squash --compress -t $TEMP_IMAGE_NAME_ARM -f Dockerfile.armhf .'
2018-07-29 09:09:40 +00:00
2018-07-30 23:09:20 +00:00
// Dockerhub
sh 'docker tag $TEMP_IMAGE_NAME_ARM docker.io/jc21/$IMAGE_NAME:$TAG_VERSION-armhf'
2018-08-24 11:29:31 +00:00
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'
2018-07-29 09:09:40 +00:00
2018-07-30 23:09:20 +00:00
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'
2018-08-24 11:29:31 +00:00
sh 'docker push docker.io/jc21/$IMAGE_NAME:$MAJOR_VERSION-armhf'
sh 'docker push docker.io/jc21/$IMAGE_NAME:latest-armhf'
2018-07-30 23:09:20 +00:00
}
2018-07-29 09:09:40 +00:00
2018-12-13 02:20:41 +00:00
// 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'
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'
}
2018-07-30 23:09:20 +00:00
sh 'docker rmi $TEMP_IMAGE_NAME_ARM'
}
2018-07-29 09:09:40 +00:00
}
2018-05-03 13:46:03 +00:00
}
2019-02-18 11:12:41 +00:00
stage('arm64') {
when {
branch 'master'
}
agent {
label 'arm64'
}
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 'rm -rf node_modules'
sh 'docker run --rm -v $(pwd):/app -w /app $BASE_IMAGE_NAME-arm64 yarn install --prod'
// Docker Build
sh 'docker build --pull --no-cache --squash --compress -t $TEMP_IMAGE_NAME_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'
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'
}
// 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'
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 rmi $TEMP_IMAGE_NAME_ARM64'
}
}
}
2018-05-03 05:43:04 +00:00
}
}
}
post {
success {
2018-07-30 23:09:20 +00:00
juxtapose event: 'success'
2018-05-17 23:33:41 +00:00
sh 'figlet "SUCCESS"'
2018-05-03 05:43:04 +00:00
}
failure {
2018-07-30 23:09:20 +00:00
juxtapose event: 'failure'
2018-05-17 23:33:41 +00:00
sh 'figlet "FAILURE"'
2018-05-03 05:43:04 +00:00
}
}
}
2018-05-03 05:56:35 +00:00
def getPackageVersion() {
2018-06-19 23:53:18 +00:00
ver = sh(script: 'docker run --rm -v $(pwd):/data $DOCKER_CI_TOOLS bash -c "cat /data/package.json|jq -r \'.version\'"', returnStdout: true)
2018-05-03 05:56:35 +00:00
return ver.trim()
}
2018-07-30 23:09:20 +00:00