Commit d3f046f9 authored by Auto Backup's avatar Auto Backup

feat: 添加专门的环境检测Jenkinsfile,只包含AGENT_LABEL参数和环境检测功能

parent 2ae80615
// 新增带返回值的跨平台 PowerShell 执行函数
def runPowerShellWithOutput(script) {
try {
if (isUnix()) {
return sh(script: "pwsh -Command \"${script}\"", returnStdout: true).trim()
} else {
return powershell(script: script, returnStdout: true).trim()
}
} catch (Exception e) {
echo "执行 PowerShell 脚本失败: ${e.message}"
throw e
}
}
pipeline {
parameters {
string(
name: 'AGENT_LABEL',
defaultValue: 'windowsPackageMachine',
description: '输入 agent 节点 (可选:ljgWinMachine or lzxWinMachine)'
)
}
agent {
label params.AGENT_LABEL
}
stages {
stage('环境检测') {
steps {
script {
try {
echo "🚀 开始运行环境检测..."
// 使用新创建的环境检测脚本
def envCheckResult = runPowerShellWithOutput("node ./check-environment.js")
echo "环境检测结果:"
echo envCheckResult
// 如果脚本返回非零退出码,这里会抛出异常
// 所以我们不需要额外检查
} catch (Exception e) {
echo "环境检测阶段发生错误: ${e.message}"
echo "⚠️ 环境检测失败,请确保以下组件已安装:"
echo "1. Node.js (https://nodejs.org/)"
echo "2. ss3ops (会自动安装,如失败请手动安装)"
currentBuild.result = 'FAILURE'
error("环境检测失败: ${e.message}")
}
}
}
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment