Update Jenkinsfile

This commit is contained in:
BrahmanapallyNagaraju 2020-04-09 18:18:06 +05:30 committed by GitHub
parent eef13b4908
commit c871decf3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

7
Jenkinsfile vendored
View file

@ -25,21 +25,20 @@ stages {
steps {
dir("spring-petclinic") {
sh """
docker build -t pet-clinic:1.0 .
docker build -t nagarajub123/pet-clinic:${params.Docker_image_base_version}.${BUILD_NUMBER} .
docker ps -q --filter name=pet-clinic_container|grep -q . && (docker stop pet-clinic_container && docker rm pet-clinic_container) ||echo pet-clinic_container doesn\\'t exists
docker run --name pet-clinic_container -d -p 8080:8080 pet-clinic:1.0
"""
}
}
}
stage('publish') {
stage('publish to docker registry') {
steps {
withCredentials([usernamePassword(credentialsId: 'hub.docker',passwordVariable: 'docker_PSW', usernameVariable: 'docker_USR')]) {
sh """
docker login -u ${docker_USR} -p ${docker_PSW}
docker images
docker tag pet-clinic:1.0 nagarajub123/pet-clinic:${params.Docker_image_base_version}.${BUILD_NUMBER}
docker push nagarajub123/pet-clinic:1.0
docker push nagarajub123/pet-clinic:${params.Docker_image_base_version}.${BUILD_NUMBER}
"""
}
}