fix: npm cache folder access
All checks were successful
jenkins-ci Build successful

This commit is contained in:
2026-01-27 11:19:12 +00:00
parent 54dc41b75a
commit 61dde9642b

18
Jenkinsfile vendored
View File

@@ -33,32 +33,32 @@ pipeline {
sh "docker run --rm --volumes-from jenkins -w \$(pwd) static-toolbox '${env.SOURCE_DIR}/**/*.html' --config .htmlhintrc" sh "docker run --rm --volumes-from jenkins -w \$(pwd) static-toolbox '${env.SOURCE_DIR}/**/*.html' --config .htmlhintrc"
} }
} }
stage('Lighthouse Audit') { stage('Lighthouse Audit') {
steps { steps {
echo "Running Lighthouse audit..." echo "Running Lighthouse audit..."
// Clean old report and containers // Clean old report and prepare reports and npm cache folders
sh """ sh """
docker run --rm --volumes-from jenkins -w \$(pwd) alpine:latest \ docker run --rm --volumes-from jenkins -w \$(pwd) alpine:latest \
sh -c "rm -rf ./.lighthouseci && mkdir -p ./.lighthouseci && chmod 777 ./.lighthouseci" sh -c "rm -rf ./.lighthouseci && mkdir -p ./.lighthouseci && chmod 777 ./.lighthouseci"
"""
sh "docker rm -f lighthouse-audit || true" # On s'assure que le dossier existe et qu'il est accessible par tous les conteneurs
docker run --rm -v /home/lucas/.npm-cache:/tmp/npm-cache alpine:latest \
sh -c "mkdir -p /tmp/npm-cache && chmod 777 /tmp/npm-cache"
"""
// Run // Run
sh """ sh """
docker run --name lighthouse-audit \ docker run --rm \
--volumes-from jenkins \ --volumes-from jenkins \
-w \$(pwd) \ -w \$(pwd) \
-e CHROME_PATH=/usr/bin/chromium-browser \
-v /home/lucas/.npm-cache:/tmp/npm-cache \ -v /home/lucas/.npm-cache:/tmp/npm-cache \
-e npm_config_cache=/tmp/npm-cache \ -e npm_config_cache=/tmp/npm-cache \
-e CHROME_PATH=/usr/bin/chromium-browser \
--entrypoint "" \ --entrypoint "" \
zenika/alpine-chrome:with-node \ zenika/alpine-chrome:with-node \
npx --prefer-offline -p @lhci/cli@0.13.0 lhci autorun --config=./.lighthouserc.cjs npx --prefer-offline -p @lhci/cli@0.13.0 lhci autorun --config=./.lighthouserc.cjs
""" """
// Clean
sh "docker rm -f lighthouse-audit"
} }
} }