diff --git a/Jenkinsfile b/Jenkinsfile index 7e925fd..b31c4d1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -38,6 +38,8 @@ pipeline { stage('Stop primary container') { steps { script { + def status_p = sh(returnStatus: true, script: 'docker images | grep bind9-primary | grep $(grep image docker-compose.yml | grep primary | awk -F\':\' \'{ print $4 }\')') + if (status_p != 0) { sh 'docker compose down' sh 'sleep 5' @@ -51,6 +53,8 @@ pipeline { stage('Start primary container') { steps { script { + def status_p = sh(returnStatus: true, script: 'docker images | grep bind9-primary | grep $(grep image docker-compose.yml | grep primary | awk -F\':\' \'{ print $4 }\')') + if (status_p != 0) { sh 'docker compose down' sh 'docker compose up -d --no-color primary' @@ -71,6 +75,8 @@ pipeline { stage('Stop secondary container') { steps { script { + def status_s = sh(returnStatus: true, script: 'docker images | grep bind9-secondary | grep $(grep image docker-compose.yml | grep secondary | awk -F\':\' \'{ print $4 }\')') + if (status_s != 0) { sh 'docker --context pi502 compose down' sh 'sleep 5' @@ -84,6 +90,8 @@ pipeline { stage('Start secondary container') { steps { script { + def status_s = sh(returnStatus: true, script: 'docker images | grep bind9-secondary | grep $(grep image docker-compose.yml | grep secondary | awk -F\':\' \'{ print $4 }\')') + if (status_s != 0) { sh 'docker --context pi502 compose up -d --no-color secondary' sh 'docker --context pi502 compose ps'