good-old-jenkins/Jenkinsfile
Andreas Fahrecker f58dc78f4e
Some checks failed
andreas-personal/good-old-jenkins/pipeline/head There was a failure building this commit
Make Jenkinsfile parallel
2024-04-16 00:24:26 +02:00

64 lines
2.2 KiB
Groovy

#!groovy
pipeline {
agent {
label 'linux'
}
stages {
stage('Build/Push Docker Image') {
when {
beforeAgent true;
branch 'main'
}
environment {
DOCKER_HUB_CREDENTIALS = credentials('docker-hub-fah16145')
}
stages {
stage('Login') {
steps {
sh 'docker login -u ${DOCKER_HUB_CREDENTIALS_USR} -p ${DOCKER_HUB_CREDENTIALS_PSW}'
}
}
stage('Build & Push') {
parallel {
stage('Default Image') {
stages {
stage('Build Default Image') {
steps {
sh 'docker build -t fah16145/good-old-jenkins:latest .'
}
}
stage('Push Default Image') {
steps {
sh 'docker push fah16145/good-old-jenkins:latest'
}
}
}
}
stage('Alpine Image') {
stages {
stage('Build Alpine Image') {
steps {
sh 'docker build -t fah16145/good-old-jenkins:alpine alpine/'
}
}
stage('Push Alpine Image') {
steps {
sh 'docker push fah16145/good-old-jenkins:alpine'
}
}
}
}
}
}
}
post {
always {
sh 'docker logout'
}
}
}
}
}