diff --git a/Jenkinsfile b/Jenkinsfile index 0e0ef36..44be564 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,9 +22,23 @@ pipeline { steps { echo '构建项目...' sh ''' + # 加载 nvm(支持多个可能的安装路径) + export NVM_DIR="$HOME/.nvm" + if [ -s "$NVM_DIR/nvm.sh" ]; then + \. "$NVM_DIR/nvm.sh" + elif [ -s "/usr/local/opt/nvm/nvm.sh" ]; then + \. "/usr/local/opt/nvm/nvm.sh" + elif [ -s "/opt/homebrew/opt/nvm/nvm.sh" ]; then + \. "/opt/homebrew/opt/nvm/nvm.sh" + fi + + # 使用 Node.js 22 + nvm use 22 2>/dev/null || nvm use default || true + # 检查 Node.js if ! command -v node &> /dev/null; then echo "错误: Node.js 未安装,请安装 Node.js 22+" + echo "提示: 如果使用 nvm,请确保已安装: nvm install 22" exit 1 fi