Commit 91831603 authored by liguangyu06's avatar liguangyu06
Browse files

Skip report publishing when Git checkout never reached the workspace.

parent d74d1e15
......@@ -162,51 +162,73 @@ pipeline {
post {
always {
junit allowEmptyResults: true, testResults: 'reports/latest/junit.xml'
archiveArtifacts artifacts: 'reports/latest/**, reports/ci-*/summary.json, reports/ci-*/meta.txt', allowEmptyArchive: true, fingerprint: true
script {
try {
junit allowEmptyResults: true, testResults: 'reports/latest/junit.xml'
} catch (err) {
echo "跳过 JUnit(代码可能尚未检出):${err}"
}
try {
archiveArtifacts artifacts: 'reports/latest/**, reports/ci-*/summary.json, reports/ci-*/meta.txt', allowEmptyArchive: true, fingerprint: true
} catch (err) {
echo "跳过归档:${err}"
}
if (fileExists('reports/latest/summary.json')) {
def descScript = 'node -e "var s=require(\'./reports/latest/summary.json\'); var c=s.counts||{}; console.log(s.suite+\' shards=\'+s.shards+\' workers=\'+s.workers+\' fail=\'+(c.failures||0)+\'/\'+(c.tests||0))"'
def desc = isUnix()
? sh(script: descScript, returnStdout: true).trim()
: bat(script: "@echo off\n${descScript}", returnStdout: true).trim()
currentBuild.description = desc
try {
def descScript = 'node -e "var s=require(\'./reports/latest/summary.json\'); var c=s.counts||{}; console.log(s.suite+\' shards=\'+s.shards+\' workers=\'+s.workers+\' fail=\'+(c.failures||0)+\'/\'+(c.tests||0))"'
def desc = isUnix()
? sh(script: descScript, returnStdout: true).trim()
: bat(script: "@echo off\n${descScript}", returnStdout: true).trim()
currentBuild.description = desc
} catch (err) {
echo "跳过构建描述:${err}"
}
}
try {
publishHTML([
allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'reports/latest/playwright-report',
reportFiles: 'index.html',
reportName: 'Playwright Report'
])
} catch (err) {
echo "跳过 HTML 报告:${err}"
}
}
publishHTML([
allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'reports/latest/playwright-report',
reportFiles: 'index.html',
reportName: 'Playwright Report'
])
script {
if (fileExists('reports/latest/allure-results')) {
try {
allure includeProperties: false, jdk: '', results: [[path: 'reports/latest/allure-results']]
} catch (err) {
echo "Allure 插件不可用,已保留 reports/latest/allure-report:${err}"
if (fileExists('reports/latest/allure-report/index.html')) {
publishHTML([
allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'reports/latest/allure-report',
reportFiles: 'index.html',
reportName: 'Allure Report'
])
try {
publishHTML([
allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'reports/latest/allure-report',
reportFiles: 'index.html',
reportName: 'Allure Report'
])
} catch (ignored) {
echo "跳过 Allure HTML:${ignored}"
}
}
}
}
withEnv(["BUILD_RESULT=${currentBuild.currentResult}"]) {
if (isUnix()) {
sh 'node scripts/ci-email-summary.mjs || true'
} else {
bat returnStatus: true, script: 'node scripts\\ci-email-summary.mjs'
try {
withEnv(["BUILD_RESULT=${currentBuild.currentResult}"]) {
if (isUnix()) {
sh 'node scripts/ci-email-summary.mjs || true'
} else {
bat returnStatus: true, script: 'node scripts\\ci-email-summary.mjs'
}
}
sendReportEmail()
} catch (err) {
echo "跳过邮件:${err}"
}
sendReportEmail()
}
}
}
......
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