118 lines
2.7 KiB
Groovy
118 lines
2.7 KiB
Groovy
pipeline {
|
|
//test 1
|
|
// 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('Self-check Jenkinsfile version') {
|
|
steps {
|
|
sh '''#!/bin/bash
|
|
set -euo pipefail
|
|
echo '==== Showing first lines of Jenkinsfile (debug) ===='
|
|
head -n 40 Jenkinsfile || true
|
|
echo 'Git commit:'
|
|
git rev-parse --short HEAD || true
|
|
'''
|
|
}
|
|
}
|
|
|
|
stage('Versions') {
|
|
steps {
|
|
sh '''#!/bin/bash
|
|
set -euo pipefail
|
|
node -v && npm -v
|
|
npx playwright --version || true
|
|
'''
|
|
}
|
|
}
|
|
|
|
stage('Verify mocks') {
|
|
steps {
|
|
sh '''#!/bin/bash
|
|
set -euo pipefail
|
|
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
|
|
'''
|
|
}
|
|
}
|
|
|
|
stage('Build') {
|
|
steps {
|
|
sh '''#!/bin/bash
|
|
set -euo pipefail
|
|
env npm_config_production=false npm ci
|
|
npm run build
|
|
'''
|
|
}
|
|
}
|
|
|
|
stage('E2E chromium') {
|
|
steps {
|
|
sh '''#!/bin/bash
|
|
set -euo pipefail
|
|
echo 'Start simulator'
|
|
npm run server:sim &
|
|
SIM_PID=$!
|
|
|
|
cleanup() {
|
|
echo 'Stopping simulator'
|
|
kill $SIM_PID 2>/dev/null || true
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
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();"
|
|
|
|
# Browser (Image hat sie normalerweise schon)
|
|
npx playwright install --with-deps chromium || true
|
|
|
|
echo 'Run tests (chromium)'
|
|
npx playwright test --project=chromium
|
|
'''
|
|
}
|
|
}
|
|
}
|
|
|
|
post {
|
|
success {
|
|
sh 'curl -d "Tests erfolgreich in Jenkins" https://ntfy.sh/OEOr8DNB0aT2mXWg231PeEEKwvuzt86qgM8ezQmgfcX9ZIlZ35'
|
|
}
|
|
failure {
|
|
sh 'curl -d "Tests fehlgeschlagen in Jenkins" https://ntfy.sh/OEOr8DNB0aT2mXWg231PeEEKwvuzt86qgM8ezQmgfcX9ZIlZ35'
|
|
}
|
|
always {
|
|
sh 'echo Workspace: $(pwd); ls -1'
|
|
}
|
|
}
|
|
}
|