59 Commits

Author SHA1 Message Date
c5d7689b97 Удаление старых образов перед деплоем
Some checks are pending
Hedgehog_server_CI/ServerMonitorBot/pipeline/pr-master Build queued...
2023-11-22 18:50:36 +03:00
2bca814b3f Удаление старых образов перед деплоем
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/pr-master This commit looks good
2023-11-22 18:45:22 +03:00
2b8a5f326c убрал лишние шаги
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CI/ServerMonitorBot/pipeline/pr-master This commit looks good
2023-11-22 11:32:44 +03:00
180e1e6be4 fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 23:21:59 +03:00
1a1fca9325 fix 2023-11-21 23:21:34 +03:00
e416a84bf7 fix
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 23:13:21 +03:00
dcd357c6e0 fix
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 23:07:59 +03:00
43958b0d7c fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-21 23:06:14 +03:00
c8ff9725e5 fix
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 23:02:25 +03:00
bac9f84092 fix
All checks were successful
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 23:01:20 +03:00
38a989e223 fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 22:59:24 +03:00
2b782867c9 fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-21 22:57:56 +03:00
3a0866dfa4 fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 22:54:57 +03:00
386dceed36 fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 22:52:56 +03:00
5d4370d932 fix 2023-11-21 22:52:17 +03:00
23effc5fe6 fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 22:49:46 +03:00
e259bb0262 fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-21 22:32:46 +03:00
9849a46a40 fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 22:22:40 +03:00
757850aae6 fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 22:16:55 +03:00
431e777988 add application.yml
Some checks failed
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-21 22:15:43 +03:00
8b8833cd2b fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 17:53:32 +03:00
754ae67714 fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 14:05:11 +03:00
7d929254dd fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 14:02:48 +03:00
d822059e4e fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-21 14:00:18 +03:00
0fecaa501b fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-21 13:59:29 +03:00
034387af16 fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-21 13:57:58 +03:00
07b27cb6de очистка от неиспользуемых образов
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 13:53:25 +03:00
28ec8dcd64 очистка от неиспользуемых образов
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 13:50:35 +03:00
de303fcd8e очистка от неиспользуемых образов
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 13:47:06 +03:00
35a8d6a8c7 очистка от неиспользуемых образов
Some checks failed
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-21 13:43:36 +03:00
bf070c29a1 CI/CD fix
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 13:33:21 +03:00
395da1739b CI/CD fix
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-21 13:28:03 +03:00
34744f93ec CI/CD fix
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-20 22:13:19 +03:00
a20b0c4963 CI/CD fix
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-20 22:07:30 +03:00
94485ab9d2 CI/CD fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 22:02:23 +03:00
204dbc5f73 CI/CD fix
All checks were successful
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-20 21:50:45 +03:00
98bc9633be CI/CD fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-20 21:47:54 +03:00
8bdc56bd8a CI/CD fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-20 21:32:28 +03:00
051e201525 CI/CD fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-20 21:30:28 +03:00
b68520ffa4 CI/CD fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head This commit looks good
2023-11-20 21:25:10 +03:00
74078b120c CI/CD fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 21:22:50 +03:00
94285d88b7 CI/CD fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 21:20:56 +03:00
008b173b70 CI/CD fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 21:19:20 +03:00
0ba76e16b2 CI/CD fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 21:17:34 +03:00
bdb19c81ca CI/CD fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 21:06:00 +03:00
d56b5a5617 CI/CD fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 20:59:34 +03:00
182f850a3b CI/CD fix
Some checks failed
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
2023-11-20 20:58:23 +03:00
11c0b4f369 CI/CD fix
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 20:55:01 +03:00
a6151fb01e CI/CD fix
Some checks failed
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
2023-11-20 20:53:40 +03:00
3c53ea17a5 CI/CD
Some checks failed
Hedgehog_server_CI/ServerMonitorBot/pipeline/head This commit looks good
Hedgehog_server_CD/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 20:49:56 +03:00
3b505398e4 build docker stage
All checks were successful
Hedgehog_server/ServerMonitorBot/pipeline/head This commit looks good
2023-11-20 20:08:55 +03:00
ead94bea2f build docker stage
Some checks failed
Hedgehog_server/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 20:06:34 +03:00
ecfd0a9ae5 build docker stage
Some checks failed
Hedgehog_server/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 19:59:20 +03:00
7a0c2fde66 fix
Some checks failed
Hedgehog_server/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 19:54:58 +03:00
56a74a8b49 Добавил стадию теста
Some checks failed
Hedgehog_server/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-20 19:52:32 +03:00
0863650ddc log errors
All checks were successful
Hedgehog_server/ServerMonitorBot/pipeline/head This commit looks good
2023-11-19 22:20:29 +03:00
02a4b5081f log errors
Some checks failed
Hedgehog_server/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-19 22:16:52 +03:00
9ef9ad18cf fix
Some checks failed
Hedgehog_server/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-19 22:15:16 +03:00
fd39b88296 fix
Some checks failed
Hedgehog_server/ServerMonitorBot/pipeline/head There was a failure building this commit
2023-11-19 22:12:16 +03:00
8 changed files with 105 additions and 52 deletions

View File

@@ -1,11 +1,11 @@
# Используем официальный образ OpenJDK 17 как базовый образ
FROM openjdk:17-jre-slim
FROM openjdk:17
# Установка рабочей директории внутри контейнера
WORKDIR /app
# Копируем JAR-файл приложения из локальной директории внутрь контейнера
COPY target/ServerMonitorBot-0.0.1-SNAPSHOT.jar app.jar
COPY ServerMonitorBot-0.0.1-SNAPSHOT.jar app.jar
# Команда для запуска Spring Boot приложения при старте контейнера
CMD ["java", "-jar", "app.jar"]

71
Jenkinsfile_CD Normal file
View File

@@ -0,0 +1,71 @@
pipeline {
agent {
docker {
image 'maven:3.9.5-eclipse-temurin-17'
args '-v /root/.m2:/root/.m2'
}
}
environment {
SSH_HOST = credentials('ROCK_PI_5_SSH_HOST')
SSH_PORT = credentials('ROCK_PI_5_SSH_PORT')
SSH_USER = credentials('ROCK_PI_5_SSH_USER')
SSH_PASS = credentials('ROCK_PI_5_SSH_PASS')
PATH_TO_DEV_FOLDER = credentials('SERVERMONITORBOT_PATH_TO_DEV_FOLDER')
IMAGE_NAME = 'servermonitorbot'
IMAGE_VERSION = 'latest'
}
stages {
stage('Init container') {
steps {
sh 'apt-get update && apt-get install -y sshpass openssh-client'
}
}
stage('Build') {
steps {
withCredentials([file(credentialsId: 'SERVERMONITORBOT_APPLICATION_YAML', variable: 'application_yaml')]) {
sh "cp -f \$application_yaml src/main/resources/application.yml"
}
sh 'mvn -B -DskipTests -X clean package spring-boot:repackage'
}
}
stage('Stop container') {
steps {
sh """
sshpass -p ${SSH_PASS} ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SSH_HOST} -p ${SSH_PORT} 'cd ${PATH_TO_DEV_FOLDER} && docker compose down'
"""
}
}
stage('Remove old image') {
steps {
sh """
sshpass -p ${SSH_PASS} ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SSH_HOST} -p ${SSH_PORT} 'docker image rm -f ${IMAGE_NAME}:${IMAGE_VERSION} || true'
"""
}
}
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}'
sshpass -p ${SSH_PASS} ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SSH_HOST} -p ${SSH_PORT} 'rm -f ${PATH_TO_DEV_FOLDER}/{*.*}'
sshpass -p ${SSH_PASS} scp -o StrictHostKeyChecking=no -P ${SSH_PORT} target/*.jar ${SSH_USER}@${SSH_HOST}:${PATH_TO_DEV_FOLDER}/
sshpass -p ${SSH_PASS} scp -o StrictHostKeyChecking=no -P ${SSH_PORT} Dockerfile ${SSH_USER}@${SSH_HOST}:${PATH_TO_DEV_FOLDER}/
sshpass -p ${SSH_PASS} scp -o StrictHostKeyChecking=no -P ${SSH_PORT} docker-compose.yml ${SSH_USER}@${SSH_HOST}:${PATH_TO_DEV_FOLDER}/
sshpass -p ${SSH_PASS} ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SSH_HOST} -p ${SSH_PORT} 'cd ${PATH_TO_DEV_FOLDER} && docker build --no-cache -t ${IMAGE_NAME}:${IMAGE_VERSION} .'
sshpass -p ${SSH_PASS} ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SSH_HOST} -p ${SSH_PORT} 'cd ${PATH_TO_DEV_FOLDER} && docker compose up -d'
"""
}
}
}
stage('Remove useless images') {
steps {
sh """
sshpass -p ${SSH_PASS} ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SSH_HOST} -p ${SSH_PORT} 'docker image prune --all --force'
"""
}
}
}
}

View File

@@ -1,14 +1,14 @@
pipeline {
agent {
docker {
image 'maven'
image 'maven:3.9.5-eclipse-temurin-17'
args '-v /root/.m2:/root/.m2'
}
}
stages {
stage('Build') {
steps {
sh 'mvn -B -DskipTests clean package'
sh 'mvn -B -DskipTests -X clean package spring-boot:repackage'
}
}
}

View File

@@ -5,10 +5,17 @@ services:
context: .
depends_on:
- db
networks:
default:
db:
image: postgres:latest
environment:
POSTGRES_USER: servermonitorbot
POSTGRES_PASSWORD: servermonitorbot
POSTGRES_DB: servermonitorbot
POSTGRES_DB: servermonitorbot
networks:
default:
networks:
default:

58
pom.xml
View File

@@ -16,9 +16,10 @@
<properties>
<java.version>17</java.version>
<flyway.version>9.16.0</flyway.version>
<db.url>${db.url}</db.url>
<db.user>${db.username}</db.user>
<db.password>${db.password}</db.password>
<db.url>${database.url}</db.url>
<db.user>${database.username}</db.user>
<db.password>${database.password}</db.password>
<start-class>ru.ldeloff.servermonitorbot.ServerMonitorBotApplication</start-class>
</properties>
<dependencies>
<dependency>
@@ -44,7 +45,7 @@
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots</artifactId>
<version>6.7.0</version>
<version>6.8.0</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
@@ -69,12 +70,15 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version> <!-- Укажите актуальную версию плагина -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<source>${java.version}</source> <!-- Укажите версию исходного кода Java -->
<target>${java.version}</target> <!-- Укажите версию целевого байт-кода Java -->
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
@@ -91,45 +95,21 @@
</execution>
</executions>
<configuration>
<url>${db.url}</url>
<user>${db.username}</user>
<password>${db.password}</password>
<url>${database.url}</url>
<user>${database.username}</user>
<password>${database.password}</password>
<locations>
<location>classpath:db/migration</location>
</locations>
</configuration>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.2.0</version>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>build-image</id>
<phase>install</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<configuration>
<imageName>ServerMonitorBot</imageName>
<serverId>remote-docker</serverId>
<dockerDirectory>.</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
<executions>
<execution>
<id>build-image</id>
<phase>package</phase>
<goals>
<goal>build</goal>
<goal>repackage</goal>
</goals>
</execution>
</executions>

View File

@@ -2,9 +2,9 @@ spring:
application:
name: ServerMonitorBot
datasource:
url: @db.url@
username: @db.username@
password: @db.password@
url: jdbc:postgresql://db:5432/servermonitorbot
username: servermonitorbot
password: servermonitorbot
jpa:
hibernate:
ddl-auto: none

View File

@@ -1,8 +1,5 @@
--liquibase formatted sql
--changeset L_DelOff:create_table_users rollbackSplitStatements:true
--comment: Создание таблицы пользователей
CREATE SCHEMA servermonitorbot;
CREATE TABLE users
(
id SERIAL PRIMARY KEY,

View File

@@ -1,5 +1,3 @@
--liquibase formatted sql
--changeset L_DelOff:create_table_roles rollbackSplitStatements:true
--comment: Создание таблицы ролей
CREATE TABLE roles