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

95
Jenkinsfile vendored
View File

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