fix: use host Jenkins workspace in Docker CI

This commit is contained in:
2026-08-04 12:01:34 +00:00
parent fbeeb518a0
commit f7f8afd484

29
Jenkinsfile vendored
View File

@@ -4,12 +4,17 @@ pipeline {
options {
disableConcurrentBuilds()
timestamps()
skipDefaultCheckout(true)
}
environment {
CI_NETWORK = "tiptop-ci-${BUILD_NUMBER}"
CI_DATABASE = "tiptop-ci-db-${BUILD_NUMBER}"
DATABASE_URL = "postgresql://tiptop_ci:tiptop_ci_password@${CI_DATABASE}:5432/the_tip_top_ci"
HOST_JENKINS_HOME = "/opt/furious-ducks/data/jenkins"
HOST_WORKSPACE = "${HOST_JENKINS_HOME}/workspace/${JOB_NAME}"
}
stages {
@@ -19,6 +24,21 @@ pipeline {
}
}
stage('Vérification du workspace') {
steps {
sh '''
echo "Workspace Jenkins : ${WORKSPACE}"
echo "Workspace hôte : ${HOST_WORKSPACE}"
ls -lah backend
test -f backend/package.json
test -f backend/package-lock.json
test -f frontend/package.json
test -f frontend/package-lock.json
'''
}
}
stage('Backend - Tests') {
steps {
sh '''
@@ -43,6 +63,7 @@ pipeline {
if [ "$i" -eq 30 ]; then
echo "PostgreSQL ne répond pas."
docker logs "${CI_DATABASE}"
exit 1
fi
@@ -56,7 +77,7 @@ pipeline {
-e DATABASE_URL="${DATABASE_URL}" \
-e JWT_SECRET=jenkins_ci_secret \
-e NODE_ENV=test \
-v "${WORKSPACE}/backend:/app" \
-v "${HOST_WORKSPACE}/backend:/app" \
-w /app \
node:22-alpine \
sh -c "
@@ -75,7 +96,7 @@ pipeline {
docker run --rm \
--user "$(id -u):$(id -g)" \
-e HOME=/tmp \
-v "${WORKSPACE}/frontend:/app" \
-v "${HOST_WORKSPACE}/frontend:/app" \
-w /app \
node:22-alpine \
sh -c "
@@ -90,6 +111,8 @@ pipeline {
stage('Docker Build') {
steps {
sh '''
cd "${WORKSPACE}"
docker compose \
-f docker-compose.dev.yml \
build
@@ -104,8 +127,6 @@ pipeline {
docker rm -f "${CI_DATABASE}" 2>/dev/null || true
docker network rm "${CI_NETWORK}" 2>/dev/null || true
'''
deleteDir()
}
success {