CI/CD
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good Details
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit Details

pull/31/head
L_DelOff 2023-11-20 20:49:56 +03:00
parent 3b505398e4
commit 3c53ea17a5
2 changed files with 41 additions and 3 deletions

41
Jenkinsfile_CD Normal file
View File

@ -0,0 +1,41 @@
pipeline {
agent {
docker {
image 'maven:3.9.5-eclipse-temurin-17'
args '-v /root/.m2:/root/.m2'
}
}
environment {
SSH_HOST = credentials('SSH_HOST')
SSH_PORT = credentials('SSH_PORT')
SSH_USER = credentials('SSH_USER')
SSH_PASS = credentials('SSH_PASS')
PATH_TO_DEV_FOLDER = credentials('PATH_TO_DEV_FOLDER')
IMAGE_NAME = servermonitorbot
IMAGE_VERSION = latest
}
stages {
stage('Build') {
steps {
sh 'mvn -B -DskipTests -X clean package'
}
}
stage('Deploy') {
steps {
script {
sh """
sshpass -p ${SSH_PASS} ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SSH_HOST} -p ${SSH_PORT} 'mkdir -p ${PATH_TO_DEV_FOLDER}'
scp -o StrictHostKeyChecking=no -P ${SSH_PORT} target/*.jar ${SSH_USER}@${SSH_HOST}:${PATH_TO_DEV_FOLDER}/
scp -o StrictHostKeyChecking=no -P ${SSH_PORT} Dockerfile ${SSH_USER}@${SSH_HOST}:${PATH_TO_DEV_FOLDER}/
scp -o StrictHostKeyChecking=no -P ${SSH_PORT} docker-compose.yml ${SSH_USER}@${SSH_HOST}:${PATH_TO_DEV_FOLDER}/
ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SSH_HOST} -p ${SSH_PORT} 'cd ${PATH_TO_DEV_FOLDER} && docker build -t ${IMAGE_NAME}:${IMAGE_VERSION} .'
ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SSH_HOST} -p ${SSH_PORT} 'cd ${PATH_TO_DEV_FOLDER} && docker-compose up -d'
"""
}
}
}
}
}
}

View File

@ -8,14 +8,11 @@ pipeline {
stages {
stage('Build') {
steps {
sh 'ls'
sh 'mvn -B -DskipTests -X clean package'
}
}
stage('Build docker') {
steps {
sh 'ls'
sh 'ls target'
sh 'docker build -t ldeloff/servermonitorbot:latest .'
}
}