File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -170,18 +170,19 @@ docker save -o node22.tar node:22
170170scp -P 2222 node22.tar root@152.22.3.186:/home/docker-images
171171` ` `
172172
173- Pipeline 脚本中使用 Docker nodejs 20 运行示例
173+ Pipeline 脚本中使用 Docker ` nodejs 20` 运行示例
174174
175175` ` ` groovy
176176pipeline {
177177 //agent any
178178 // pipeline 放到 docker 中执行
179179 agent {
180180 docker {
181- // 使用 Node.js 18 的 Docker 镜像
182- image 'node:20'
183- // 可选:挂载 NPM 缓存目录,加速构建
184- args '-v /root/.npm:/root/.npm'
181+ // 使用 Node.js 18 的 Docker 镜像
182+ image 'node:20'
183+ // 可选:挂载 NPM 缓存目录,加速构建
184+ // 使用 Jenkins 工作空间中的 .npm 目录作为缓存目录,不会有权限写入问题
185+ args '-v ${JENKINS_HOME}/.npm:/home/node/.npm'
185186 }
186187 }
187188 environment {
@@ -232,7 +233,7 @@ pipeline {
232233 sh '''
233234 ls -la
234235 cd h5_vip
235- npm install --registry=https://registry.npmmirror.com/
236+ npm install --cache /home/node/.npm -- registry=https://registry.npmmirror.com/
236237 ls -la
237238 npm run build
238239 ls -la
@@ -319,7 +320,7 @@ scp -P 2222 my-openjdk-maven.3.8.7.tar root@106.55.8.163:/home/docker-images
319320docker load -i ./my-openjdk-maven.3.8.7.tar
320321` ` `
321322
322- 这事缓存下载的 maven 的包
323+ 缓存下载的 ` maven` 的包
323324
324325` ` ` sh
325326docker run -it --rm my-openjdk-maven:3.8.7 /bin/bash
You can’t perform that action at this time.
0 commit comments