fix: Jenkinsfile
This commit is contained in:
116
Jenkinsfile
vendored
116
Jenkinsfile
vendored
@@ -1,65 +1,92 @@
|
||||
// Jenkinsfile
|
||||
pipeline {
|
||||
agent any
|
||||
tools { nodejs 'node20' }
|
||||
agent {
|
||||
// Wir nutzen das Playwright-Image auch als Build-/Test-Container
|
||||
// (enthält Node, Browser & nötige Deps)
|
||||
docker {
|
||||
image 'mcr.microsoft.com/playwright:v1.54.2-jammy'
|
||||
// optional: args '--user root' falls Rechte benötigt werden
|
||||
reuseNode true
|
||||
}
|
||||
}
|
||||
|
||||
options { timestamps() }
|
||||
options {
|
||||
timestamps()
|
||||
ansiColor('xterm')
|
||||
}
|
||||
|
||||
environment {
|
||||
CI = 'true'
|
||||
NODE_ENV = 'production'
|
||||
NEXT_TELEMETRY_DISABLED = '1'
|
||||
PORT = '3000'
|
||||
HUSKY = '0'
|
||||
npm_config_fund = 'false'
|
||||
npm_config_audit = 'false'
|
||||
CI = "true"
|
||||
NODE_ENV = "production"
|
||||
NEXT_TELEMETRY_DISABLED = "1"
|
||||
PORT = "3000"
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Verify mocks') {
|
||||
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
// Standard-Checkout; läuft im Container
|
||||
checkout scm
|
||||
|
||||
// LFS & Submodule wie in Woodpecker aktivieren
|
||||
sh '''
|
||||
set -eu
|
||||
echo "[Verify mocks] repo file check"
|
||||
echo "Node available?"; node -v; npm -v
|
||||
echo "Check file exists"
|
||||
if [ -f mocks/device-cgi-simulator/SERVICE/systemMockData.js ]; then
|
||||
echo 'FOUND'
|
||||
else
|
||||
echo 'MISSING'; exit 1
|
||||
fi
|
||||
set -eux
|
||||
# Falls LFS verwendet wird:
|
||||
if command -v git >/dev/null; then
|
||||
git lfs install || true
|
||||
# Submodule + LFS-Dateien sicherstellen
|
||||
git submodule update --init --recursive || true
|
||||
# LFS-Dateien ziehen (falls vorhanden)
|
||||
git lfs fetch || true
|
||||
git lfs checkout || true
|
||||
fi
|
||||
|
||||
# Debug: kurzer Baumüberblick
|
||||
git status --short || true
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('Install & Build') {
|
||||
stage('verify-mocks') {
|
||||
steps {
|
||||
sh '''
|
||||
set -eu
|
||||
echo 'Install dependencies (incl dev)'
|
||||
env npm_config_production=false npm ci
|
||||
echo 'Build app'
|
||||
npm run build
|
||||
set -eux
|
||||
pwd
|
||||
node -v && npm -v
|
||||
|
||||
# Husky/prepare überspringen wie im Woodpecker-Job
|
||||
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 chromium') {
|
||||
stage('e2e-dev') {
|
||||
steps {
|
||||
sh '''
|
||||
set -eu
|
||||
echo 'Start simulator'
|
||||
npm run server:sim &
|
||||
SIM_PID=$!
|
||||
trap 'echo Stopping simulator; kill $SIM_PID 2>/dev/null || true' EXIT
|
||||
set -eux
|
||||
node -v && npm -v
|
||||
|
||||
echo 'Wait for http://localhost:3000'
|
||||
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();"
|
||||
# Husky als devDep nicht ausführen -> npm_config_production=false
|
||||
env npm_config_production=false npm ci
|
||||
|
||||
echo 'Ensure chromium available'
|
||||
npx playwright install chromium || true
|
||||
npm run build
|
||||
|
||||
echo 'Run tests'
|
||||
npx playwright test --project=chromium
|
||||
# Sim-Server im Hintergrund starten
|
||||
npm run server:sim &
|
||||
|
||||
# Auf Port 3000 warten (ohne curl)
|
||||
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();"
|
||||
|
||||
# Playwright Tests
|
||||
npx playwright test --project=chromium
|
||||
'''
|
||||
}
|
||||
}
|
||||
@@ -67,13 +94,20 @@ npx playwright test --project=chromium
|
||||
|
||||
post {
|
||||
success {
|
||||
sh 'curl -d "Tests erfolgreich in Jenkins" https://ntfy.sh/OEOr8DNB0aT2mXWg231PeEEKwvuzt86qgM8ezQmgfcX9ZIlZ35'
|
||||
sh '''
|
||||
set -eux
|
||||
curl -d "Tests erfolgreich in woodpecker" https://ntfy.sh/OEOr8DNB0aT2mXWg231PeEEKwvuzt86qgM8ezQmgfcX9ZIlZ35
|
||||
'''
|
||||
}
|
||||
failure {
|
||||
sh 'curl -d "Tests fehlgeschlagen in Jenkins" https://ntfy.sh/OEOr8DNB0aT2mXWg231PeEEKwvuzt86qgM8ezQmgfcX9ZIlZ35'
|
||||
sh '''
|
||||
set -eux
|
||||
curl -d "Tests fehlgeschlagen in woodpecker" https://ntfy.sh/OEOr8DNB0aT2mXWg231PeEEKwvuzt86qgM8ezQmgfcX9ZIlZ35
|
||||
'''
|
||||
}
|
||||
always {
|
||||
sh 'echo Workspace: $(pwd); ls -1'
|
||||
// Optional: Artefakte, Logs, Playwright-Reports archivieren
|
||||
// archiveArtifacts artifacts: 'playwright-report/**', onlyIfSuccessful: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user