mirror of
https://github.com/parrazam/radicale-docker.git
synced 2024-11-24 17:39:13 +01:00
Tagged latest version with version
This commit is contained in:
parent
f3ed5c6768
commit
20dd93dfed
1 changed files with 75 additions and 34 deletions
107
Jenkinsfile
vendored
107
Jenkinsfile
vendored
|
@ -1,54 +1,78 @@
|
||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
parameters {
|
|
||||||
string(name: 'version', description: 'Version from base image')
|
|
||||||
}
|
|
||||||
environment {
|
environment {
|
||||||
SOURCE = "tomsquest/docker-radicale"
|
SOURCE = "tomsquest/docker-radicale"
|
||||||
TARGET = "parrazam/radicale-with-infcloud"
|
TARGET = "parrazam/radicale-with-infcloud"
|
||||||
MASTER_BRANCH = "master"
|
MASTER_BRANCH = "master"
|
||||||
|
RELEASE_BRANCH = "release/*"
|
||||||
|
VERSION = ''
|
||||||
}
|
}
|
||||||
options {
|
options {
|
||||||
skipStagesAfterUnstable()
|
skipStagesAfterUnstable()
|
||||||
}
|
}
|
||||||
stages {
|
stages {
|
||||||
|
stage('Configure pipeline for branch type') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
if (env.BRANCH_NAME.startsWith('release/')) {
|
||||||
|
VERSION = (env.BRANCH_NAME).tokenize('/')[1]
|
||||||
|
} else if (env.BRANCH_NAME.equals('master')) {
|
||||||
|
VERSION = ''
|
||||||
|
} else {
|
||||||
|
VERSION = '-SNAPSHOT'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
stage('Delete older images') {
|
stage('Delete older images') {
|
||||||
steps {
|
steps {
|
||||||
echo "Removing existing images in local..."
|
echo "Removing existing images in local..."
|
||||||
sh "docker images | grep ${TARGET} | tr -s ' ' | cut -d ' ' -f 2 | xargs -I {} docker rmi ${TARGET}:{}"
|
sh "docker images | grep ${TARGET} | tr -s ' ' | cut -d ' ' -f 2 | xargs -I {} docker rmi ${TARGET}:{}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Build AMD64 image') {
|
stage("Build image") {
|
||||||
steps {
|
matrix {
|
||||||
echo "Building ${TARGET}:amd64${params.version} image..."
|
axes {
|
||||||
sh "docker pull ${SOURCE}:amd64${params.version}"
|
axis {
|
||||||
sh "docker buildx build -t ${TARGET}:amd64${params.version} --platform linux/amd64 ."
|
name 'PLATFORM'
|
||||||
}
|
values 'linux/amd64', 'linux/386', 'linux/arm64', 'linux/arm/v7'
|
||||||
}
|
}
|
||||||
stage('Build 386 image') {
|
}
|
||||||
steps {
|
stages {
|
||||||
echo "Building ${TARGET}:386${params.version} image..."
|
stage('Build by platform') {
|
||||||
sh "docker pull ${SOURCE}:386${params.version}"
|
options {
|
||||||
sh "docker buildx build -t ${TARGET}:386${params.version} --platform linux/386 ."
|
lock( 'synchronous-matrix' )
|
||||||
}
|
}
|
||||||
}
|
steps {
|
||||||
stage('Build ARM image') {
|
echo "Building for ${PLATFORM}"
|
||||||
steps {
|
script {
|
||||||
echo "Building ${TARGET}:arm${params.version} image..."
|
stage("Build ${PLATFORM}") {
|
||||||
sh "docker pull ${SOURCE}:arm${params.version}"
|
script {
|
||||||
sh "docker buildx build -t ${TARGET}:arm${params.version} --platform linux/arm/v7 ."
|
SOURCE_IMAGE = SOURCE+':'+PLATFORM.tokenize('/')[1]
|
||||||
}
|
TARGET_IMAGE = TARGET+':'+PLATFORM.tokenize('/')[1]
|
||||||
}
|
if (env.BRANCH_NAME.startsWith('release/')) {
|
||||||
stage('Build ARM64 image') {
|
SOURCE_IMAGE += "." + VERSION
|
||||||
steps {
|
TARGET_IMAGE += "." + VERSION
|
||||||
echo "Building ${TARGET}:arm64${params.version} image..."
|
} else {
|
||||||
sh "docker pull ${SOURCE}:arm64${params.version}"
|
TARGET_IMAGE += VERSION
|
||||||
sh "docker buildx build -t ${TARGET}:arm64${params.version} --platform linux/arm64 ."
|
}
|
||||||
|
}
|
||||||
|
echo "Building ${TARGET_IMAGE} image..."
|
||||||
|
sh "docker pull ${SOURCE_IMAGE}"
|
||||||
|
sh "docker buildx build -t ${TARGET_IMAGE} --platform ${PLATFORM} ."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Publish images to Docker Hub') {
|
stage('Publish images to Docker Hub') {
|
||||||
when {
|
when {
|
||||||
branch "${MASTER_BRANCH}"
|
anyOf {
|
||||||
|
branch "${MASTER_BRANCH}"
|
||||||
|
branch "${RELEASE_BRANCH}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
withCredentials([usernamePassword(credentialsId: 'dockerHub', passwordVariable: 'dockerHubPassword', usernameVariable: 'dockerHubUser')]) {
|
withCredentials([usernamePassword(credentialsId: 'dockerHub', passwordVariable: 'dockerHubPassword', usernameVariable: 'dockerHubUser')]) {
|
||||||
|
@ -59,17 +83,34 @@ pipeline {
|
||||||
}
|
}
|
||||||
stage('Tagging with common version') {
|
stage('Tagging with common version') {
|
||||||
environment {
|
environment {
|
||||||
GROUPED_VERSION = "latest"
|
GROUPED_VERSION = "${VERSION}"
|
||||||
}
|
}
|
||||||
when {
|
when {
|
||||||
branch "${MASTER_BRANCH}"
|
anyOf {
|
||||||
|
branch "${MASTER_BRANCH}"
|
||||||
|
branch "${RELEASE_BRANCH}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
sh "docker manifest create ${TARGET}:${GROUPED_VERSION} -a ${TARGET}:amd64${params.version} -a ${TARGET}:386${params.version} -a ${TARGET}:arm${params.version} -a ${TARGET}:arm64${params.version}"
|
script {
|
||||||
|
if (VERSION.equals('')) {
|
||||||
|
GROUPED_VERSION = 'latest'
|
||||||
|
}
|
||||||
|
if (env.BRANCH_NAME.startsWith('release/')) {
|
||||||
|
VERSION = '.' + (env.BRANCH_NAME).tokenize('/')[1]
|
||||||
|
}
|
||||||
|
IMAGES = ''
|
||||||
|
for (ARCH in ['linux/amd64', 'linux/386', 'linux/arm64', 'linux/arm/v7']) {
|
||||||
|
IMAGES += ' -a ' + TARGET + ':' + ARCH.tokenize('/')[1] + VERSION
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "${IMAGES}"
|
||||||
|
sh "docker manifest create ${TARGET}:${GROUPED_VERSION} ${IMAGES}"
|
||||||
sh "docker manifest push ${TARGET}:${GROUPED_VERSION}"
|
sh "docker manifest push ${TARGET}:${GROUPED_VERSION}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
post {
|
post {
|
||||||
always {
|
always {
|
||||||
echo "Removing existing images in local..."
|
echo "Removing existing images in local..."
|
||||||
|
|
Loading…
Reference in a new issue