Summary
Investigation into how Jenkins calculates the "Age" value for test results shows that the current behavior does not always reflect the real state of a test. Specifically, tests marked as "skipped/unknown" cause Age to keep incrementing instead of resetting, even when the test isn't actually failing.
How Jenkins currently calculates Age
- Jenkins parses
junitResult.xml on each build, looking for tags that mark a test as failed.
- If a test is marked as failed, its Age counter is incremented.
- On the next build, Jenkins checks the XML again:
- If the test fails again, Age increments further.
- If the entire build fails/goes red (a build regression), Age is not reset, since Jenkins can't determine whether the original failure is still present or not.
- Age only resets to 0 once the test passes on a green build.
The bug / unexpected behavior
If a test is skipped for any reason, Jenkins deciding to skip it, the test being temporarily disabled, a "skip" parameter being added, etc. during a yellow or green build, Jenkins marks that test result as "unknown" instead of pass/fail.
- An "unknown" result does not reset the Age counter.
- If the same test is skipped again later, Age keeps increasing.
- This means a test that hasn't actually failed in a long time can still show a high/inflated Age, since skips are being (incorrectly) treated the same as failures for aging purposes.
Related: JUnit History feature
For context, the "History" graph (part of the JUnit plugin, often installed by default on Jenkins) works in a similar way to Age:
- It reads the same
junitResult.xml files.
- It records pass/fail status per build to build the trend graphic.
Work done so far
- Wrote a script that calculates a "real" Age value, applying corrected conditions (i.e., not counting "unknown/skipped" results as continuations of a failure streak). The purpose isn't to take this age as the real one, but instead define which rules to calculate the age we need to the
buildfarmers dashboard.
- With a small additional function, the same script can also generate the History trend manually using
matplotlib, independent of the plugin's own rendering.
Summary
Investigation into how Jenkins calculates the "Age" value for test results shows that the current behavior does not always reflect the real state of a test. Specifically, tests marked as "skipped/unknown" cause Age to keep incrementing instead of resetting, even when the test isn't actually failing.
How Jenkins currently calculates Age
junitResult.xmlon each build, looking for tags that mark a test as failed.The bug / unexpected behavior
If a test is skipped for any reason, Jenkins deciding to skip it, the test being temporarily disabled, a "skip" parameter being added, etc. during a yellow or green build, Jenkins marks that test result as "unknown" instead of pass/fail.
Related: JUnit History feature
For context, the "History" graph (part of the JUnit plugin, often installed by default on Jenkins) works in a similar way to Age:
junitResult.xmlfiles.Work done so far
buildfarmers dashboard.matplotlib, independent of the plugin's own rendering.