Commit fe65124c authored by liguangyu06's avatar liguangyu06
Browse files

Launch Playwright via local CLI on Windows instead of spawning npx.cmd.

parent 87ddd5b6
......@@ -17,17 +17,17 @@ def sendReportEmail() {
def body = fileExists('reports/latest/email-summary.html')
? readFile(encoding: 'UTF-8', file: 'reports/latest/email-summary.html')
: "<p>构建 ${currentBuild.currentResult},未生成摘要。请打开 <a href='${env.BUILD_URL}'>Jenkins</a></p>"
if (cc) {
to = [to, cc].findAll { it }.join(',')
}
try {
emailext(
to: to,
cc: cc,
subject: subject,
body: body,
mimeType: 'text/html',
charset: 'UTF-8',
attachLog: false,
attachmentsPattern: 'reports/latest/email-summary.html,reports/latest/email-summary.txt',
recipientProviders: []
attachmentsPattern: 'reports/latest/email-summary.html,reports/latest/email-summary.txt'
)
echo "已发送报告邮件至 ${to}(正文为摘要+报告链接,附件为 email-summary.html)"
} catch (err) {
......@@ -40,7 +40,10 @@ def runCi() {
if (isUnix()) {
sh 'node scripts/run-ci.mjs --suite="$SUITE" --shards="$SHARDS"'
} else {
bat 'node scripts\\run-ci.mjs --suite=%SUITE% --shards=%SHARDS%'
bat '''
set PATH=C:\\Program Files\\nodejs;%PATH%
node scripts\\run-ci.mjs --suite=%SUITE% --shards=%SHARDS%
'''
}
}
......
......@@ -28,6 +28,7 @@ import { fileURLToPath } from 'node:url';
import { formatSuiteList, getSuite } from '../config/suites.config.mjs';
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const PLAYWRIGHT_CLI = path.join(ROOT, 'node_modules/playwright/cli.js');
function parseArgs(argv) {
const out = {
......@@ -140,12 +141,13 @@ async function preflight(baseURL) {
}
function runPlaywright(args, env) {
return new Promise((resolve) => {
const child = spawn('npx', ['playwright', 'test', ...args], {
return new Promise((resolve, reject) => {
const child = spawn(process.execPath, [PLAYWRIGHT_CLI, 'test', ...args], {
cwd: ROOT,
env,
stdio: 'inherit',
});
child.on('error', reject);
child.on('exit', (code) => resolve(code ?? 1));
});
}
......@@ -229,7 +231,7 @@ function mergeAllureResults(sourceDirs, dest) {
function mergeBlobHtml(blobDir, htmlDir) {
if (!existsSync(blobDir) || readdirSync(blobDir).length === 0) return false;
const result = spawnSync('npx', ['playwright', 'merge-reports', blobDir, '--reporter', 'html'], {
const result = spawnSync(process.execPath, [PLAYWRIGHT_CLI, 'merge-reports', blobDir, '--reporter', 'html'], {})
cwd: ROOT,
stdio: 'inherit',
env: {
......
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