Files
CPLv4.0/Jenkinsfile
2025-09-08 08:49:48 +02:00

96 lines
2.7 KiB
Groovy

pipeline {
agent any
environment {
CI = "true"
NODE_ENV = "production"
NEXT_TELEMETRY_DISABLED = "1"
PORT = "3000"
}
options {
timestamps()
}
stages {
stage('Checkout') {
steps {
checkout scm
sh '''
set -eux
git status --short || true
# Submodule & LFS falls vorhanden
git submodule update --init --recursive || true
git lfs install || true
git lfs fetch || true
git lfs checkout || true
'''
}
}
stage('verify-mocks') {
steps {
sh '''
set -eux
docker run --rm -v "$PWD":/ws -w /ws \
mcr.microsoft.com/playwright:v1.54.2-jammy bash -lc "
pwd
node -v && npm -v
npm ci --ignore-scripts
echo '=== git ls-files ==='
git ls-files | grep -i '^mocks/device-cgi-simulator/SERVICE/systemMockData.js' || true
echo '=== ls -la ==='
ls -la mocks/device-cgi-simulator/SERVICE || true
echo '=== file exists? ==='
test -f mocks/device-cgi-simulator/SERVICE/systemMockData.js && echo 'FOUND' || (echo 'MISSING' && exit 1)
"
'''
}
}
stage('e2e-dev') {
steps {
sh '''
set -eux
docker run --rm -v "$PWD":/ws -w /ws -p 3000:3000 \
mcr.microsoft.com/playwright:v1.54.2-jammy bash -lc "
node -v && npm -v
env npm_config_production=false npm ci
npm run build
npm run server:sim &
# Auf Port 3000 warten
node -e \\"const http=require('http');let n=120;function ping(){http.get('http://localhost:3000',res=>{console.log('Server is up');process.exit(0)}).on('error',()=>{if(n--<=0){console.error('Server did not start');process.exit(1)}setTimeout(ping,1000)});}ping();\\"
npx playwright test --project=chromium
"
'''
}
}
}
post {
success {
sh '''
docker run --rm curlimages/curl:8.9.1 \
-d "Tests erfolgreich in Jenkins" \
https://ntfy.sh/OEOr8DNB0aT2mXWg231PeEEKwvuzt86qgM8ezQmgfcX9ZIlZ35
'''
}
failure {
sh '''
docker run --rm curlimages/curl:8.9.1 \
-d "Tests fehlgeschlagen in Jenkins" \
https://ntfy.sh/OEOr8DNB0aT2mXWg231PeEEKwvuzt86qgM8ezQmgfcX9Z35
'''
}
always {
script {
if (fileExists('playwright-report')) {
archiveArtifacts artifacts: 'playwright-report/**', onlyIfSuccessful: false
} else {
echo 'Kein playwright-report gefunden.'
}
}
}
}
}