File tree 1 file changed +8
-7
lines changed 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
170
170
scp -P 2222 node22.tar [email protected] :/home/docker-images
171
171
` ` `
172
172
173
- Pipeline 脚本中使用 Docker nodejs 20 运行示例
173
+ Pipeline 脚本中使用 Docker ` nodejs 20` 运行示例
174
174
175
175
` ` ` groovy
176
176
pipeline {
177
177
//agent any
178
178
// pipeline 放到 docker 中执行
179
179
agent {
180
180
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'
185
186
}
186
187
}
187
188
environment {
@@ -232,7 +233,7 @@ pipeline {
232
233
sh '''
233
234
ls -la
234
235
cd h5_vip
235
- npm install --registry=https://registry.npmmirror.com/
236
+ npm install --cache /home/node/.npm -- registry=https://registry.npmmirror.com/
236
237
ls -la
237
238
npm run build
238
239
ls -la
@@ -319,7 +320,7 @@ scp -P 2222 my-openjdk-maven.3.8.7.tar
[email protected] :/home/docker-images
319
320
docker load -i ./my-openjdk-maven.3.8.7.tar
320
321
` ` `
321
322
322
- 这事缓存下载的 maven 的包
323
+ 缓存下载的 ` maven` 的包
323
324
324
325
` ` ` sh
325
326
docker run -it --rm my-openjdk-maven:3.8.7 /bin/bash
You can’t perform that action at this time.
0 commit comments