我能够看到在html报告中创建的以下路径,当它是本地作业时,我能够从html打开此路径,但是当我在jenkins中运行时,此链接将无法工作,我能够看到元数据具有url和工作区信息,我可以使用这些元数据在html文件中生成适当的链接,这样我就能从jenkins页面中打开它们。
href="file:///space/scratch/jenkins/navarro/workspace/coverage_regression/dut/python/.simtest/NavarroSimTestSystem/default/TestJaxi/test_py_jaxi_read_version_reg_ss/TestJaxi.test_py_jaxi_read_version_reg_ss-2458081572_simulate.log" type="text/plain">TestJaxi.test_py_jaxi_read_version_reg_ss-2458081572_simulate.log
答案 0 :(得分:0)
您是否要显示Jenkins工作的测试结果?我发现使用--junitxml开关将jenkins指向Junit XML路径更容易生成junit.xml。它显示所有测试结果数据。或者您是否尝试过“ html-publisher-plugin”。
答案 1 :(得分:0)
我通过以下方法发现了。
def pytest_configure(self, config):
# below lines has been added to manipulate the log path in html report while running in jenkins
if 'BUILD_URL' in config._metadata:
self.build_url = os.path.join(config._metadata['BUILD_URL'],'artifact')
@pytest.mark.optionalhook
def pytest_html_results_table_html(self, report, data):
if test_artifact_simulate and os.path.isfile(test_artifact_command):
from py.xml import html
ul = html.ul()
if self.build_url != None :
simulate_log = test_artifact_simulate[test_artifact_simulate.find('dut'):]
print 'KKT simulate log is %s' %simulate_log
jenkins_log_path = os.path.join(self.build_url,simulate_log)
print 'KKT jenkins_log_path log is %s' %jenkins_log_path
li = html.li(html.a(os.path.basename(test_artifact_simulate),
href= jenkins_log_path, type="text/plain"))
else :
li = html.li(html.a(os.path.basename(test_artifact_simulate),
href='file://' + test_artifact_simulate, type="text/plain"))
ul.append(li)
div = html.div()
div.append(html.p("Test artifacts:"))
div.append(ul)
data.append(div)