pipeline { environment { REGISTRY_URL = "https://proxy.docker.dataekb.ru/local_cache" REGISTRY = "proxy.docker.dataekb.ru/local_cache" BOT_IMAGE_NAME = "bot_open_sesam" TUNNEL_IMAGE_NAME = "tunnel_open_sesam" BOT_IMAGE_TAG = "latest" TUNNEL_IMAGE_TAG = "latest" } agent { label 'agent_smith'} stages { stage ('build bot image and push') { steps { script { docker.withRegistry("${REGISTRY_URL}", 'jenkins_harbor') { def BotImage = docker.build( "${REGISTRY}/${BOT_IMAGE_NAME}:${BOT_IMAGE_TAG}" ) BotImage.push() } } } } stage ('build tunnel image and push') { steps { dir('tunnel'){ script { docker.withRegistry("${REGISTRY_URL}", 'jenkins_harbor') { def TunnelImage = docker.build( "${REGISTRY}/${TUNNEL_IMAGE_NAME}:${TUNNEL_IMAGE_TAG}" ) TunnelImage.push() } } } } } stage ('clear after build and push') { steps { script { sh "docker image prune --filter label=stage=builder" } } } stage("Deploy") { steps { script { sh ''' docker-compose pull docker-compose up -d ''' } } } } post { success { echo "Оба образа собраны и задеплоены успешно" } failure { echo "Ошибка сборки!" } } } // Old_version // pipeline { // agent { label 'agent_smith' } // // stages { // stage('Stop and Remove Existing Container') { // steps { // sh ''' // docker stop open_sesam || true // docker rm open_sesam || true // docker-compose down || true // ''' // } // } // // stage('Build and Run Container') { // steps { // sh ''' // docker-compose up --build -d // ''' // } // } // } // }