jenkins-with-docker/Jenkinsfile
Andreas Fahrecker 225469414f
Some checks failed
andreas-personal/jenkins-with-docker/pipeline/head There was a failure building this commit
Added Jenkins Build Steps fro alpine Build
2024-03-12 16:43:22 +01:00

62 lines
1.9 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/jenkins-with-docker:latest .'
}
}
stage('Push') {
steps {
sh 'docker push fah16145/jenkins-with-docker:latest'
}
}
}
}
stage('Alpine Image') {
stages {
stage('Build') {
steps {
sh 'cd alpine'
sh 'docker build -t fah16145/jenkins-with-docker:alpine .'
}
}
stage('Push') {
steps {
sh 'docker push fah16145/jenkins-with-docker:alpine'
}
}
}
}
}
post {
always {
sh 'docker logout'
}
}
}
}
}