Skip to content

Delete temporary output folder after zipping painted sources#753

Merged
uhafner merged 1 commit into
jenkinsci:mainfrom
jonathanrdunn:fix-temp-directory-cleanup-issue
May 11, 2026
Merged

Delete temporary output folder after zipping painted sources#753
uhafner merged 1 commit into
jenkinsci:mainfrom
jonathanrdunn:fix-temp-directory-cleanup-issue

Conversation

@jonathanrdunn
Copy link
Copy Markdown
Contributor

This change fixes a workspace cleanup gap in source-code retention handling for coverage reports.

When painted source files are generated, the plugin creates a temporary directory in the agent workspace named after the recordCoverage id (for example: my-coverage-report), writes per-file zipped painted sources into that directory, then zips the directory into coverage-sources.zip for transfer to the controller. The transfer zip is cleaned up, but the temporary id-named directory was not deleted, so it remained in the agent workspace after each build.

Open Issue

This PR addresses GitHub Issue #752: coverage-sources.zip is left behind in agent workspace after each build

Root Cause

In AgentCoveragePainter.invoke(...), the code zips outputFolder into coverage-sources.zip, but cleanup only removed the JVM temp folder used during rendering. The outputFolder itself (workspace/id) was never deleted.

What Changed

  • Added cleanup of the agent workspace temporary output folder after zipping is complete.
  • Kept existing behavior for creating per-file zipped painted sources and packaging them into coverage-sources.zip.
  • Did not change coverage parsing, metrics calculations, source rendering content, or retention semantics.

Why I Think This Solution Is Safe

  • The id-named workspace folder is a transport/staging artifact used only before packaging.
  • Deleting it after successful packaging does not affect the extracted artifacts stored in the build folder on the controller.
  • The change is scoped to artifact lifecycle cleanup only.

Behavior Before vs After

Before: workspace/id temporary folder remained after builds.

After: workspace/id temporary folder is deleted after packaging, so no temporary painted-source folder remains in the agent workspace root.

Impact

  • Prevents accumulation and visibility of temporary .zip artifacts in id-named workspace folders.
  • Reduces workspace clutter and avoids unexpected untracked artifacts in environments that validate workspace cleanliness.

Testing Done

I did not run this code or write unit tests. I do not have a Java environment set up to compile this project. I am hoping one of the maintainers can pull this branch, write or run a basic test, and ensure that testing requirements for this project are met.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

Disclaimer

This PR is provided in good faith as a starting point to resolve GitHub Issue #752. The submitter expects maintainers to verify that this is the correct fix and that the changes behave according to project expectations.

@github-actions
Copy link
Copy Markdown

☀️   Quality Monitor

Tests

   JUnit   Unit Tests: ✅ successful — 191 passed
   🚀   Integration Tests: ✅ successful — 148 passed, 7 skipped
   ⛔   Architecture Tests: ✅ successful — 15 passed

Coverage for New Code

   〰️   Line Coverage: 100.00% — perfect 🎉
   ➰   Branch Coverage: 100.00% — perfect 🎉

Coverage for Whole Project

   〰️   Line Coverage: 76.33% — 726 missed lines
   ➰   Branch Coverage: 66.59% — 293 missed branches

Style

   CheckStyle   CheckStyle: No warnings
   PMD   PMD: No warnings
   ☕   Java Compiler: No warnings

Bugs

   SpotBugs   SpotBugs: No bugs
   🐛   Error Prone: No bugs

Vulnerabilities

   🛡️   OWASP Dependency Check: 200 vulnerabilities — error: 16, high: 50, normal: 127, low: 7

Software Metrics

   🌀   Cyclomatic Complexity: 1031 (total)
   💭   Cognitive Complexity: 564 (total)
   ➿   N-Path Complexity: 1387 (total)
   📏   Lines of Code: 12064 (total)
   📝   Non Commenting Source Statements: 4070 (total)
   🔗   Class Cohesion: 100.00% (maximum)
   ⚖️   Weight of Class: 100.00% (maximum)

🚦 Quality Gates

Overall Status: ✅ SUCCESS

✅ Passed Gates

  • ✅ Overall Tests Success Rate: 100.00 >= 100.00
  • ✅ Line Coverage in New Code: 100.00 >= 90.00
  • ✅ Branch Coverage in New Code: 100.00 >= 90.00
  • ✅ Potential Bugs in Whole Project: 0.00 <= 0.00
  • ✅ Style Violation in Whole Project: 0.00 <= 0.00

Created by Quality Monitor v4.11.0 (#484bbba). More details are shown in the GitHub Checks Result.

@uhafner uhafner merged commit b5a8809 into jenkinsci:main May 11, 2026
31 of 32 checks passed
@uhafner uhafner changed the title Coverage plugin: delete temporary output folder after zipping painted sources Delete temporary output folder after zipping painted sources May 11, 2026
@jonathanrdunn jonathanrdunn deleted the fix-temp-directory-cleanup-issue branch May 12, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Bugs or performance problems

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A directory with the same name as the value given for the id parameter is left behind in agent workspace after each build

2 participants