Jenkins集成Allure报告后旧测试用例残留问题咨询
Yep, I’ve dealt with this exact issue when integrating Allure with Jenkins—let’s walk through how to get your report to only show active test cases along with their history, ditching the removed ones entirely:
Configure Allure’s History Filtering Policy
By default, Allure retains every test case it’s ever tracked in the history. To change this, you can set the history policy to only include cases present in your current test run:- In Jenkins’ Allure Report configuration, look for the History Settings section. Enable the "Filter history items" option and select Only items present in current results.
- If you’re generating reports via command line, add the flag
--history-policy=CURRENTwhen running theallure generatecommand.
Clean Up Old Allure Results Before Each Build
Sometimes leftover result files from previous runs stick around and keep old test cases in the history. Add a pre-build step in Jenkins to wipe the results directory:- For Linux/macOS: Run
rm -rf allure-results/ - For Windows: Run
rd /s /q allure-results
This ensures each build starts fresh with only the new TestNG execution results.
- For Linux/macOS: Run
Adjust Build Tool Configurations (Maven/Gradle)
If you’re using Allure with Maven or Gradle, set the history policy directly in your build file:- Maven (pom.xml)
<plugin> <groupId>io.qameta.allure</groupId> <artifactId>allure-maven</artifactId> <version>2.17.3</version> <configuration> <reportVersion>2.17.3</reportVersion> <historyPolicy>CURRENT</historyPolicy> </configuration> </plugin> - Gradle (build.gradle)
allure { report { historyPolicy = "CURRENT" } }
- Maven (pom.xml)
Verify and Manually Clean if Needed
After setting up the above steps, run a build and check theallure-report/historydirectory in your Jenkins workspace. If any old test case files are still present, delete them manually once. Subsequent builds will automatically only retain history for the 200 active test cases.
Once you implement these changes, your Allure report will only display the currently executed 200 test cases, complete with their full run history—no more clutter from the 100 removed ones.
内容的提问来源于stack exchange,提问作者Nikunj Aggarwal




