Commit 39cf33bd authored by liguangyu06's avatar liguangyu06
Browse files

Use Windows Allure CLI and a Jenkins-managed commandline so Allure reports generate on CI.

parent 93e5410e
......@@ -220,7 +220,7 @@ pipeline {
}
try {
if (fileExists('reports/latest/allure-results')) {
allure includeProperties: false, jdk: '', results: [[path: 'reports/latest/allure-results']]
allure commandline: 'allure', includeProperties: false, jdk: '', results: [[path: 'reports/latest/allure-results']]
} else {
echo '无 allure-results,跳过 Allure 插件报告。'
}
......
......@@ -157,12 +157,21 @@ function tryGenerateAllure(resultsDir, reportDir) {
console.log('[allure] 无 results,跳过 generate');
return false;
}
const cli = path.join(ROOT, 'node_modules/allure-commandline/bin/allure');
const cmd = existsSync(cli) ? cli : 'allure';
const bat = path.join(ROOT, 'node_modules/allure-commandline/dist/bin/allure.bat');
const unix = path.join(ROOT, 'node_modules/allure-commandline/bin/allure');
const cmd = process.platform === 'win32' && existsSync(bat) ? bat : existsSync(unix) ? unix : 'allure';
const env = { ...process.env };
if (!env.JAVA_HOME) {
env.JAVA_HOME = 'E:\\Program Files\\Java\\jdk-11';
}
const javaBin = path.join(env.JAVA_HOME, 'bin');
env.PATH = `${javaBin}${path.delimiter}${env.PATH || ''}`;
console.log(`[allure] generate via ${cmd}`);
const result = spawnSync(cmd, ['generate', resultsDir, '-o', reportDir, '--clean'], {
cwd: ROOT,
stdio: 'inherit',
env: process.env,
env,
shell: process.platform === 'win32',
});
if (result.status !== 0) {
console.warn('[allure] generate 失败(常见原因:节点未装 Java)。Playwright HTML / JUnit 仍可用。');
......
Supports Markdown
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