Skip to content

Commit a2f70b1

Browse files
committed
doc: update jenkins config.
1 parent 9b1a441 commit a2f70b1

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

docs/jenkins/README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,18 +170,19 @@ docker save -o node22.tar node:22
170170
scp -P 2222 node22.tar [email protected]:/home/docker-images
171171
```
172172

173-
Pipeline 脚本中使用 Docker nodejs 20 运行示例
173+
Pipeline 脚本中使用 Docker `nodejs 20` 运行示例
174174

175175
```groovy
176176
pipeline {
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 [email protected]:/home/docker-images
319320
docker load -i ./my-openjdk-maven.3.8.7.tar
320321
```
321322

322-
这事缓存下载的 maven 的包
323+
缓存下载的 `maven` 的包
323324

324325
```sh
325326
docker run -it --rm my-openjdk-maven:3.8.7 /bin/bash

0 commit comments

Comments
 (0)