From 35aa7fb6bcdcfa0ff19d0ec5621169bc1c136341 Mon Sep 17 00:00:00 2001 From: kurihada Date: Tue, 3 Mar 2026 15:17:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20Jenkins=20=E5=AE=B9?= =?UTF-8?q?=E5=99=A8=E5=86=85=E7=9C=8B=E4=B8=8D=E5=88=B0=20lockfile=20?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d8fc03e..73d1b6d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,16 +22,11 @@ pipeline { } } - stage('Install Dependencies') { + stage('Prepare Test Images') { steps { sh ''' - docker run --rm \ - -u $(id -u):$(id -g) \ - -e HOME=/tmp \ - -v "$WORKSPACE":/workspace \ - -w /workspace \ - node:20-bookworm \ - sh -lc "npm ci" + docker pull node:20-bookworm + docker pull mcr.microsoft.com/playwright:v1.51.1-jammy ''' } } @@ -39,13 +34,11 @@ pipeline { stage('Quality Gate') { steps { sh ''' - docker run --rm \ - -u $(id -u):$(id -g) \ - -e HOME=/tmp \ - -v "$WORKSPACE":/workspace \ - -w /workspace \ - node:20-bookworm \ - sh -lc "npm run lint && npx tsc --noEmit && npm run test:coverage" + set -e + cid=$(docker create node:20-bookworm sh -lc "cd /workspace && npm ci && npm run lint && npx tsc --noEmit && npm run test:coverage") + trap 'docker rm -f "$cid" >/dev/null 2>&1 || true' EXIT + docker cp . "$cid":/workspace + docker start -a "$cid" ''' } } @@ -56,14 +49,20 @@ pipeline { } steps { sh ''' - docker run --rm \ - --ipc=host \ - -u $(id -u):$(id -g) \ - -e HOME=/tmp \ - -v "$WORKSPACE":/workspace \ - -w /workspace \ - mcr.microsoft.com/playwright:v1.51.1-jammy \ - sh -lc "npm run test:e2e" + set -e + cid=$(docker create --ipc=host mcr.microsoft.com/playwright:v1.51.1-jammy sh -lc "cd /workspace && npm ci && npm run test:e2e") + cleanup() { + docker rm -f "$cid" >/dev/null 2>&1 || true + } + trap cleanup EXIT + docker cp . "$cid":/workspace + set +e + docker start -a "$cid" + status=$? + set -e + docker cp "$cid":/workspace/playwright-report ./playwright-report 2>/dev/null || true + docker cp "$cid":/workspace/test-results ./test-results 2>/dev/null || true + exit $status ''' } post {