good-old-jenkins/Jenkinsfile
Andreas Fahrecker 552ed8a7a5
All checks were successful
andreas-personal/good-old-jenkins/pipeline/head This commit looks good
Initial Commit
2024-03-14 21:31:22 +01:00

61 lines
1.8 KiB
Groovy

#!groovy
pipeline {
agent none
stages {
stage('Build/Push Docker Image') {
when {
beforeAgent true;
branch 'main'
}
agent {
label 'linux'
}
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('Default Image') {
stages {
stage('Build') {
steps {
sh 'docker build -t fah16145/good-old-jenkins:latest .'
}
}
stage('Push') {
steps {
sh 'docker push fah16145/good-old-jenkins:latest'
}
}
}
}
stage('Alpine Image') {
stages {
stage('Build') {
steps {
sh 'docker build -t fah16145/good-old-jenkins:alpine alpine/'
}
}
stage('Push') {
steps {
sh 'docker push fah16145/good-old-jenkins:alpine'
}
}
}
}
}
post {
always {
sh 'docker logout'
}
}
}
}
}