Docker automate in Jenkinsfile
BOT_open_sesam/pipeline/head There was a failure building this commit
Details
BOT_open_sesam/pipeline/head There was a failure building this commit
Details
parent
b2363215b8
commit
e4f596dd82
|
|
@ -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
|
||||
// '''
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
|
|
|||
Loading…
Reference in New Issue