Added Jenkinsfile
All checks were successful
andreas-personal/jenkins-with-docker/pipeline/head This commit looks good

This commit is contained in:
Andreas Fahrecker 2023-04-18 14:52:27 +02:00
parent fe3fd6d640
commit 25156a931b
2 changed files with 43 additions and 0 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
.idea/
*.iml

42
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,42 @@
#!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('Build') {
steps {
sh 'docker build -t fah16145/jenkins-with-docker:latest .'
}
}
stage('Login') {
steps {
sh 'docker login -u ${DOCKER_HUB_CREDENTIALS_USR} -p ${DOCKER_HUB_CREDENTIALS_PSW}'
}
}
stage('Push') {
steps {
sh 'docker push fah16145/jenkins-with-docker:latest'
}
}
}
post {
always {
sh 'docker logout'
}
}
}
}
}