Jenkinsfile auf Woodpecker-Parität umgestellt:
This commit is contained in:
106
Jenkinsfile
vendored
106
Jenkinsfile
vendored
@@ -1,61 +1,88 @@
|
||||
pipeline {
|
||||
agent any
|
||||
tools { nodejs 'node20' } // exakt der Name aus "Manage Jenkins → Tools"
|
||||
// Nutze das gleiche Playwright-Image wie Woodpecker für Parität
|
||||
agent {
|
||||
docker {
|
||||
image 'mcr.microsoft.com/playwright:v1.54.2-jammy'
|
||||
// root erlaubt playwright install (falls nötig)
|
||||
args '-u 0:0'
|
||||
}
|
||||
}
|
||||
|
||||
options { timestamps() }
|
||||
|
||||
environment {
|
||||
CI = 'true'
|
||||
NODE_ENV = 'production'
|
||||
NEXT_TELEMETRY_DISABLED = '1'
|
||||
PORT = '3000'
|
||||
HUSKY = '0' // Husky Hooks im CI deaktivieren
|
||||
npm_config_fund = 'false'
|
||||
npm_config_audit = 'false'
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Versions') {
|
||||
steps { sh 'node -v && npm -v' }
|
||||
steps {
|
||||
sh 'node -v && npm -v && npx playwright --version'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Verify mocks') {
|
||||
steps {
|
||||
sh '''
|
||||
# dash (/bin/sh) on Jenkins does not support -o pipefail; keep -e -u -x
|
||||
set -eux
|
||||
npm ci
|
||||
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)
|
||||
'''
|
||||
sh '''bash -euo pipefail <<'EOF'
|
||||
echo "[Verify mocks] working dir: $(pwd)"
|
||||
node -v && npm -v
|
||||
echo "HUSKY=$HUSKY"
|
||||
npm ci
|
||||
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? ==="
|
||||
if [ -f mocks/device-cgi-simulator/SERVICE/systemMockData.js ]; then
|
||||
echo 'FOUND'
|
||||
else
|
||||
echo 'MISSING'; exit 1
|
||||
fi
|
||||
EOF"""
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build & E2E (chromium)') {
|
||||
environment {
|
||||
CI = 'true'
|
||||
NODE_ENV = 'production'
|
||||
NEXT_TELEMETRY_DISABLED = '1'
|
||||
PORT = '3000'
|
||||
}
|
||||
stage('Build') {
|
||||
steps {
|
||||
sh '''
|
||||
# dash (/bin/sh) on Jenkins does not support -o pipefail; keep -e -u -x
|
||||
set -eux
|
||||
# Install devDependencies as well (rimraf, cross-env, etc.)
|
||||
env npm_config_production=false npm ci
|
||||
sh '''bash -euo pipefail <<'EOF'
|
||||
env npm_config_production=false npm ci
|
||||
npm run build
|
||||
EOF"""
|
||||
}
|
||||
}
|
||||
|
||||
# Build Next.js
|
||||
npm run build
|
||||
stage('E2E chromium') {
|
||||
steps {
|
||||
sh '''bash -euo pipefail <<'EOF'
|
||||
echo 'Start simulator'
|
||||
npm run server:sim &
|
||||
SIM_PID=$!
|
||||
|
||||
# Start local static simulator in background
|
||||
npm run server:sim &
|
||||
cleanup() {
|
||||
echo 'Stopping simulator'
|
||||
kill $SIM_PID 2>/dev/null || true
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
# Ensure Playwright browsers and OS deps are installed (best-effort)
|
||||
npx playwright install-deps || true
|
||||
npx playwright install
|
||||
echo 'Waiting 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();"
|
||||
|
||||
# Wait until simulator responds on port 3000 (no curl dependency)
|
||||
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();"
|
||||
# Browser (Image hat sie normalerweise schon)
|
||||
npx playwright install --with-deps chromium || true
|
||||
|
||||
# Run tests (chromium only to match Woodpecker)
|
||||
npx playwright test --project=chromium
|
||||
'''
|
||||
echo 'Run tests (chromium)'
|
||||
npx playwright test --project=chromium
|
||||
EOF"""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
success {
|
||||
sh 'curl -d "Tests erfolgreich in Jenkins" https://ntfy.sh/OEOr8DNB0aT2mXWg231PeEEKwvuzt86qgM8ezQmgfcX9ZIlZ35'
|
||||
@@ -63,5 +90,8 @@ pipeline {
|
||||
failure {
|
||||
sh 'curl -d "Tests fehlgeschlagen in Jenkins" https://ntfy.sh/OEOr8DNB0aT2mXWg231PeEEKwvuzt86qgM8ezQmgfcX9ZIlZ35'
|
||||
}
|
||||
always {
|
||||
sh 'echo Workspace: $(pwd); ls -1'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user