From e5de73566972bb3f791003462d51c8b2b728889e Mon Sep 17 00:00:00 2001 From: qiaoxinjiu Date: Sat, 9 May 2026 16:19:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DJenkins=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E6=97=B6allure=E6=8A=A5=E5=91=8A=E5=90=88=E5=B9=B6=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=8C=E8=BF=90=E8=A1=8C=E6=B5=8B=E8=AF=95=E5=89=8D?= =?UTF-8?q?=E6=B8=85=E7=A9=BAallure-results=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zhyy/test_case/run_tests.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/zhyy/test_case/run_tests.py b/zhyy/test_case/run_tests.py index 4be604a..d0494db 100644 --- a/zhyy/test_case/run_tests.py +++ b/zhyy/test_case/run_tests.py @@ -30,6 +30,19 @@ def ensure_dirs(): os.makedirs(ALLURE_REPORT_DIR, exist_ok=True) +def clean_allure_results(): + """清空allure-results目录,避免与上次构建的报告合并""" + if os.path.exists(ALLURE_RESULTS_DIR): + for item in os.listdir(ALLURE_RESULTS_DIR): + item_path = os.path.join(ALLURE_RESULTS_DIR, item) + if os.path.isfile(item_path): + os.remove(item_path) + elif os.path.isdir(item_path): + import shutil + shutil.rmtree(item_path) + print(f"已清空 allure-results 目录: {ALLURE_RESULTS_DIR}") + + def run_pytest(args_list): """执行pytest命令""" # 设置PYTHONPATH环境变量 @@ -273,6 +286,9 @@ def main(): # 确保目录存在 ensure_dirs() + # 清空上次构建的allure-results,避免报告合并 + clean_allure_results() + # 执行测试 exit_code = 0