Added Jenkinsfile with Build/Push
All checks were successful
andreas-personal/jenkins-ssh-docker-agent/pipeline/head This commit looks good
All checks were successful
andreas-personal/jenkins-ssh-docker-agent/pipeline/head This commit looks good
This commit is contained in:
parent
c102955f53
commit
cb9e0ab186
42
Jenkinsfile
vendored
Normal file
42
Jenkinsfile
vendored
Normal 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-ssh-docker-agent: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-ssh-docker-agent:latest'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
sh 'docker logout'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user