fixed jenkins

This commit is contained in:
2026-06-11 11:42:09 +03:00
parent 1aa39fc4b2
commit 533f047e45
Vendored
+22 -30
View File
@@ -1,16 +1,12 @@
// Деплой Home AI Assistant на grigosserver. // Home AI Assistant — деплой на Linux (Docker).
// //
// Jenkins: New Item → Pipeline → Pipeline script from SCM → этот репозиторий. // Нода Jenkins: Labels = linux (Manage Jenkins → Nodes → мастер → Configure)
// Агент: хост с Docker, где лежит ~/to_services/Home_assistant (label ниже).
// //
// Один раз на сервере: // На сервере: /home/grigo/to_services/Home_assistant (.env, data/)
// git clone <repo-url> ~/to_services/Home_assistant
// cp .env.example .env # OPENROUTER_API_KEY и прочее
// mkdir -p data
pipeline { pipeline {
agent { agent {
label 'мастер' label 'linux'
} }
options { options {
@@ -34,12 +30,12 @@ pipeline {
string( string(
name: 'BACKEND_HEALTH_URL', name: 'BACKEND_HEALTH_URL',
defaultValue: 'http://127.0.0.1:8202/api/v1/health', defaultValue: 'http://127.0.0.1:8202/api/v1/health',
description: 'Проверка после деплоя' description: 'Healthcheck после деплоя'
) )
booleanParam( booleanParam(
name: 'RUN_TESTS', name: 'RUN_TESTS',
defaultValue: true, defaultValue: true,
description: 'npm run build + compileall в workspace Jenkins' description: 'npm run build + compileall в workspace перед деплоем'
) )
booleanParam( booleanParam(
name: 'DOCKER_PULL', name: 'DOCKER_PULL',
@@ -57,6 +53,22 @@ pipeline {
} }
stages { stages {
stage('Test') {
when {
expression { return params.RUN_TESTS }
}
steps {
sh '''
set -euxo pipefail
cd frontend
if [ -f package-lock.json ]; then npm ci; else npm install; fi
npm run build
cd ..
python3 -m compileall -q backend/app
'''
}
}
stage('Preflight') { stage('Preflight') {
steps { steps {
sh ''' sh '''
@@ -70,26 +82,6 @@ pipeline {
} }
} }
stage('Test') {
when {
expression { return params.RUN_TESTS }
}
steps {
sh '''
set -euxo pipefail
cd frontend
if [ -f package-lock.json ]; then
npm ci
else
npm install
fi
npm run build
cd ..
python3 -m compileall -q backend/app
'''
}
}
stage('Deploy') { stage('Deploy') {
steps { steps {
dir("${DEPLOY_DIR}") { dir("${DEPLOY_DIR}") {