mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-18 05:25:50 +00:00
add dockerhub-demo jenkinsfile and add version to dockerfile (#17)
* add dockerhub-demo jenkinsfile and add version to dockerfile * library is loaded in implicitly * needed to use double quotes on push * commenting out push for now * commenting out push for now * added repo to hub * separate build and push stages * formatting
This commit is contained in:
parent
6eabad7c63
commit
0ea1b5309a
2 changed files with 39 additions and 1 deletions
|
@ -1,3 +1,3 @@
|
|||
FROM tomcat:9.0-alpine
|
||||
|
||||
LABEL version = "1.1.2"
|
||||
COPY target/petclinic.war /usr/local/tomcat/webapps/petclinic.war
|
||||
|
|
38
jenkinsfiles/dockerhub-demo
Normal file
38
jenkinsfiles/dockerhub-demo
Normal file
|
@ -0,0 +1,38 @@
|
|||
pipeline {
|
||||
agent none
|
||||
stages {
|
||||
stage('Build') {
|
||||
agent {
|
||||
docker {
|
||||
image 'maven:3.5.0'
|
||||
}
|
||||
}
|
||||
steps {
|
||||
sh 'mvn clean install -DskipTests=true -B'
|
||||
}
|
||||
}
|
||||
stage('Build container') {
|
||||
agent any
|
||||
steps {
|
||||
script {
|
||||
sh "docker build -t liatrio/petclinic-tomcat:${env.BRANCH_NAME} ."
|
||||
if ( ${env.BRANCH_NAME} == 'master' ) {
|
||||
def containerVersion = getVersionFromContainer("liatrio/petclinic-tomcat:${env.BRANCH_NAME}")
|
||||
failIfVersionExists("liatrio","petclinic-tomcat",containerVersion)
|
||||
sh "docker build -t liatrio/petclinic-tomcat:${containerVersion} ."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Push to dockerhub') {
|
||||
agent any
|
||||
steps {
|
||||
script {
|
||||
if ( ${env.BRANCH_NAME} == 'master' )
|
||||
sh "docker push liatrio/petclinic-tomcat:${containerVersion}"
|
||||
else sh "docker push liatrio/petclinic-tomcat:${env.BRANCH_NAME}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue