Work around docker's BS
Some checks failed
ecodash/pipeline/head There was a failure building this commit

This commit is contained in:
MassiveBox 2023-07-22 15:37:59 +02:00
parent 153b507a69
commit d5d6aa4d08
Signed by: massivebox
GPG key ID: 9B74D3A59181947D

45
jenkins/Jenkinsfile vendored
View file

@ -26,23 +26,41 @@ pipeline {
}
}
stage('Prepare buildx') {
stage('Prepare container build') {
steps {
sh """
docker buildx create --name $BUILDER_NAME
docker buildx use $BUILDER_NAME
docker buildx inspect --bootstrap
cp jenkins/Dockerfile ./Dockerfile
"""
}
}
stage('Build multi-arch container') {
steps {
withCredentials([usernamePassword(credentialsId: 'gitea-credentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh 'docker login -u $USERNAME -p $PASSWORD $DOCKER_REGISTRY'
}
unstash 'dockerfile'
unstash 'ecodash_x86'
unstash 'ecodash_arm'
unstash 'templates'
sh 'cp jenkins/Dockerfile ./Dockerfile; docker buildx build --platform linux/amd64,linux/arm64 --load -t ecodash .'
}
}
stage('Build and push container on push to master') {
when {
anyOf {
branch 'master'
buildingTag()
}
}
steps {
sh 'docker buildx build --platform linux/amd64,linux/arm64 --push -t $DOCKER_REGISTRY/$SERVICE:latest .'
}
}
stage('Build and push container on tag') {
when { buildingTag() }
steps {
def formattedTag = env.TAG_NAME.replaceFirst(/^v/, '')
sh 'docker buildx build --platform linux/amd64,linux/arm64 --push -t $DOCKER_REGISTRY/$SERVICE:$formattedTag .'
}
}
@ -55,19 +73,6 @@ pipeline {
}
}
stage('Publish container on tag latest') {
when { branch 'master' }
steps {
withCredentials([usernamePassword(credentialsId: 'gitea-credentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh 'docker login -u $USERNAME -p $PASSWORD $DOCKER_REGISTRY'
}
sh """
docker image tag ecodash $DOCKER_REGISTRY/$SERVICE:latest
docker push $DOCKER_REGISTRY/$SERVICE:latest
"""
}
}
}
post {