nginx-proxy-manager/Jenkinsfile

116 lines
4.4 KiB
Plaintext
Raw Normal View History

2018-05-03 15:43:04 +10:00
pipeline {
options {
2018-06-20 09:53:18 +10:00
buildDiscarder(logRotator(numToKeepStr: '10'))
2018-05-03 15:43:04 +10:00
disableConcurrentBuilds()
}
agent any
environment {
IMAGE_NAME = "nginx-proxy-manager"
TEMP_IMAGE_NAME = "nginx-proxy-manager-build_${BUILD_NUMBER}"
TEMP_IMAGE_NAME_ARM = "nginx-proxy-manager-arm-build_${BUILD_NUMBER}"
TAG_VERSION = getPackageVersion()
2018-05-03 16:07:34 +10:00
}
2018-05-03 15:43:04 +10:00
stages {
stage('Prepare') {
2018-06-20 10:31:10 +10:00
steps {
sh 'docker pull $DOCKER_CI_TOOLS'
2018-05-03 15:43:04 +10:00
}
}
stage('Build x86_64') {
2018-05-03 16:07:34 +10:00
steps {
ansiColor('xterm') {
sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app jc21/node:latest yarn --registry=$NPM_REGISTRY install'
2018-07-27 08:36:09 +10:00
sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app jc21/node:latest npm runscript build'
sh 'rm -rf node_modules'
sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app jc21/node yarn --registry=$NPM_REGISTRY install --prod'
sh 'docker run --rm -v $(pwd):/data $DOCKER_CI_TOOLS node-prune'
sh 'docker build --pull --no-cache --squash --compress -t $TEMP_IMAGE_NAME .'
}
}
}
2018-07-27 08:36:09 +10:00
//stage('Build armhf') {
// steps {
// ansiColor('xterm') {
// sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app jc21/node:armhf yarn --registry=$NPM_REGISTRY install'
// sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app jc21/node:armhf npm run-script build'
// sh 'rm -rf node_modules'
// sh 'docker run --rm -v $(pwd):/srv/app -w /srv/app jc21/node:armhf yarn --registry=$NPM_REGISTRY install --prod'
// sh 'docker run --rm -v $(pwd):/data $DOCKER_CI_TOOLS node-prune'
// sh 'docker build --pull --no-cache --squash --compress -t $TEMP_IMAGE_NAME_ARM -f Dockerfile.armhf .'
// }
// }
//}
2018-06-20 10:31:10 +10:00
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'
sh 'docker tag $TEMP_IMAGE_NAME_ARM ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:$TAG_VERSION-armhf'
sh 'docker push ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:$TAG_VERSION-armhf'
2018-06-20 10:31:10 +10:00
}
}
stage('Publish Public') {
2018-05-03 23:46:03 +10:00
when {
branch 'master'
}
2018-05-03 15:43:04 +10:00
steps {
2018-05-03 23:46:03 +10:00
sh 'docker tag $TEMP_IMAGE_NAME ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:latest'
sh 'docker push ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:latest'
2018-05-04 00:05:29 +10:00
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'
2018-05-03 15:43:04 +10:00
2018-07-27 08:36:09 +10:00
//sh 'docker tag $TEMP_IMAGE_NAME_ARM docker.io/jc21/$IMAGE_NAME:latest-armhf'
//sh 'docker tag $TEMP_IMAGE_NAME_ARM docker.io/jc21/$IMAGE_NAME:$TAG_VERSION-armhf'
2018-05-04 00:13:36 +10:00
withCredentials([usernamePassword(credentialsId: 'jc21-dockerhub', passwordVariable: 'dpass', usernameVariable: 'duser')]) {
2018-06-20 10:31:10 +10:00
sh "docker login -u '${duser}' -p '${dpass}'"
2018-05-04 00:05:29 +10:00
sh 'docker push docker.io/jc21/$IMAGE_NAME:latest'
sh 'docker push docker.io/jc21/$IMAGE_NAME:$TAG_VERSION'
2018-07-27 08:36:09 +10:00
//sh 'docker push docker.io/jc21/$IMAGE_NAME:latest-armhf'
//sh 'docker push docker.io/jc21/$IMAGE_NAME:$TAG_VERSION-armhf'
2018-05-03 23:46:03 +10:00
}
2018-05-03 15:43:04 +10:00
}
}
stage('Publish Beta') {
when {
branch 'v2-rewrite'
}
steps {
sh 'docker tag $TEMP_IMAGE_NAME ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:preview'
sh 'docker push ${DOCKER_PRIVATE_REGISTRY}/$IMAGE_NAME:preview'
sh 'docker tag $TEMP_IMAGE_NAME docker.io/jc21/$IMAGE_NAME:preview'
2018-07-27 08:36:09 +10:00
//sh 'docker tag $TEMP_IMAGE_NAME_ARM docker.io/jc21/$IMAGE_NAME:preview-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:preview'
2018-07-27 08:36:09 +10:00
//sh 'docker push docker.io/jc21/$IMAGE_NAME:preview-armhf'
}
}
}
2018-05-03 15:43:04 +10:00
}
triggers {
bitbucketPush()
}
post {
success {
2018-06-20 09:53:18 +10:00
juxtapose event: 'success'
2018-05-18 09:33:41 +10:00
sh 'figlet "SUCCESS"'
2018-05-03 15:43:04 +10:00
}
failure {
2018-06-20 09:53:18 +10:00
juxtapose event: 'failure'
2018-05-18 09:33:41 +10:00
sh 'figlet "FAILURE"'
2018-05-03 15:43:04 +10:00
}
2018-05-04 11:38:52 +10:00
always {
sh 'docker rmi $TEMP_IMAGE_NAME'
2018-07-27 08:36:09 +10:00
//sh 'docker rmi $TEMP_IMAGE_NAME_ARM'
2018-05-04 11:38:52 +10:00
}
2018-05-03 15:43:04 +10:00
}
}
2018-05-03 15:56:35 +10:00
def getPackageVersion() {
2018-06-20 09:53:18 +10: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 15:56:35 +10:00
return ver.trim()
}