From df03fb778a562bb97f6d1ff5235423dc7e60d8f4 Mon Sep 17 00:00:00 2001 From: caoyuchun <335003032@qq.com> Date: Tue, 20 Jan 2026 13:39:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9jenkins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index a7a5367..5662078 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,10 +24,17 @@ pipeline { stage('Test Node.js') { steps { echo '测试 Node.js 环境...' + script { + // 使用 tool 指令确保 Node.js 在 PATH 中 + def nodejs = tool name: 'NodeJS-22', type: 'hudson.plugins.nodejs.tools.NodeJSInstallation' + env.PATH = "${nodejs}/bin:${env.PATH}" + } sh ''' # 检查 Node.js 是否安装 if ! command -v node &> /dev/null; then echo "❌ 错误: Node.js 未安装,请安装 Node.js 22+" + echo "检查常见路径..." + ls -la /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS-22/bin/ 2>/dev/null || true exit 1 fi