Docker automate in Jenkinsfile
BOT_open_sesam/pipeline/head There was a failure building this commit Details

main
dl 2026-02-04 12:03:16 +05:00
parent b2363215b8
commit e4f596dd82
1 changed files with 77 additions and 18 deletions

77
Jenkinsfile vendored
View File

@ -1,23 +1,82 @@
pipeline { pipeline {
agent { label 'agent_smith' } agent {
node {
label "agent_smith"
docker {
image "docker:stable"
}
}
}
environment {
REGISTRY_URL = "https://proxy.docker.dataekb.ru/harbor/projects/3/repositories"
IMAGE_NAME = "open_sesam"
IMAGE_TAG = "latest"
}
stages { stages {
stage('Stop and Remove Existing Container') { stage("Build Docker Image") {
steps { steps {
sh ''' script {
docker stop open_sesam || true docker.build("${IMAGE_NAME}:${IMAGE_TAG}")
docker rm open_sesam || true }
docker-compose down || true
'''
} }
} }
stage('Build and Run Container') { stage('Push to Harbor') {
steps { steps {
script {
docker.withRegistry("{REGISTRY_URL}", "harbor-credentials") {
docker.image("${IMAGE_NAME}:${IMAGE_TAG}").push()
}
}
}
}
stage("Deploy") {
steps {
script {
sh ''' sh '''
docker-compose up --build -d docker-compose pull
docker-compose up -d
''' '''
} }
} }
} }
}
post {
failure {
echo "[ERROR] Build failure"
}
success {
echo "[OK] Build success"
}
}
} }
// 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
// '''
// }
// }
// }
// }