Initial Commit
All checks were successful
andreas-personal/good-old-jenkins/pipeline/head This commit looks good
All checks were successful
andreas-personal/good-old-jenkins/pipeline/head This commit looks good
This commit is contained in:
60
Jenkinsfile
vendored
Normal file
60
Jenkinsfile
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
#!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'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user