Merge pull request #20 from liatrio/LDOP-301-dockerhub-push

Ldop 301 dockerhub push
This commit is contained in:
HunterMayers 2017-09-14 15:34:05 -07:00 committed by GitHub
commit c9b33de94d
2 changed files with 28 additions and 3 deletions

2
Jenkinsfile vendored
View file

@ -12,7 +12,7 @@ pipeline {
configFileProvider(
[configFile(fileId: 'nexus', variable: 'MAVEN_SETTINGS')]) {
sh 'mvn -s $MAVEN_SETTINGS clean deploy -DskipTests=true -B'
}
}
}
}
}

View file

@ -29,14 +29,23 @@ pipeline {
stage('Build container') {
agent any
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') {
agent any
steps {
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') {
@ -57,6 +66,22 @@ pipeline {
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') {
agent any
steps {