deploy only when branch is master

This commit is contained in:
BrahmanapallyNagaraju 2020-04-14 00:02:38 +05:30 committed by GitHub
parent 152664bd2c
commit 832dcf31fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

6
Jenkinsfile vendored
View file

@ -30,6 +30,9 @@ stages {
} }
stage("deploy") { stage("deploy") {
steps { steps {
when {
branch 'master'
}
dir("spring-petclinic") { dir("spring-petclinic") {
sh """ sh """
docker build -t nagarajub123/pet-clinic:${params.Docker_image_base_version}.${BUILD_NUMBER} . docker build -t nagarajub123/pet-clinic:${params.Docker_image_base_version}.${BUILD_NUMBER} .
@ -40,6 +43,9 @@ stages {
} }
} }
stage('publish to docker registry') { stage('publish to docker registry') {
when {
branch 'master'
}
steps { steps {
withCredentials([usernamePassword(credentialsId: 'hub.docker',passwordVariable: 'docker_PSW', usernameVariable: 'docker_USR')]) { withCredentials([usernamePassword(credentialsId: 'hub.docker',passwordVariable: 'docker_PSW', usernameVariable: 'docker_USR')]) {
sh """ sh """