mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-19 14:05:50 +00:00
Merge pull request #20 from liatrio/LDOP-301-dockerhub-push
Ldop 301 dockerhub push
This commit is contained in:
commit
c9b33de94d
2 changed files with 28 additions and 3 deletions
|
@ -29,14 +29,23 @@ pipeline {
|
||||||
stage('Build container') {
|
stage('Build container') {
|
||||||
agent any
|
agent any
|
||||||
steps {
|
steps {
|
||||||
sh 'docker build -t petclinic-tomcat .'
|
script {
|
||||||
|
sh "docker build -t liatrio/petclinic-tomcat:${env.BRANCH_NAME} ."
|
||||||
|
if ( env.BRANCH_NAME == 'master' ) {
|
||||||
|
pom = readMavenPom file: 'pom.xml'
|
||||||
|
containerVersion = pom.version
|
||||||
|
/*Need to check if version exists in the future*/
|
||||||
|
/*failIfVersionExists("liatrio","petclinic-tomcat",containerVersion)*/
|
||||||
|
sh "docker build -t liatrio/petclinic-tomcat:${containerVersion} ."
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Run local container') {
|
stage('Run local container') {
|
||||||
agent any
|
agent any
|
||||||
steps {
|
steps {
|
||||||
sh 'docker rm -f petclinic-tomcat-temp || true'
|
sh 'docker rm -f petclinic-tomcat-temp || true'
|
||||||
sh 'docker run -d --network=${LDOP_NETWORK_NAME} --name petclinic-tomcat-temp petclinic-tomcat'
|
sh "docker run -d --network=${LDOP_NETWORK_NAME} --name petclinic-tomcat-temp liatrio/petclinic-tomcat:${env.BRANCH_NAME}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Smoke-Test & OWASP Security Scan') {
|
stage('Smoke-Test & OWASP Security Scan') {
|
||||||
|
@ -57,6 +66,22 @@ pipeline {
|
||||||
sh 'docker rm -f petclinic-tomcat-temp || true'
|
sh 'docker rm -f petclinic-tomcat-temp || true'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stage('Push to dockerhub') {
|
||||||
|
agent any
|
||||||
|
steps {
|
||||||
|
withCredentials([usernamePassword(credentialsId: 'dockerhub', passwordVariable: 'dockerPassword', usernameVariable: 'dockerUsername')]){
|
||||||
|
script {
|
||||||
|
sh "docker login -u ${env.dockerUsername} -p ${env.dockerPassword}"
|
||||||
|
if ( env.BRANCH_NAME == 'master' ) {
|
||||||
|
sh "docker push liatrio/petclinic-tomcat:${containerVersion}"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sh "docker push liatrio/petclinic-tomcat:${env.BRANCH_NAME}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
stage('Deploy to dev') {
|
stage('Deploy to dev') {
|
||||||
agent any
|
agent any
|
||||||
steps {
|
steps {
|
||||||
|
|
Loading…
Reference in a new issue