TeamCity
 
You are viewing the documentation for an earlier version of TeamCity.

Build Files Cleaner (Swabra)

Last modified: 20 April 2023

Bundled Swabra plugin allows to clean files created during the build.

The plugin remembers the state of the file tree after the sources checkout and deletes all the newly added files at the end of the build or at next build start depending on the settings. Swabra also detects modified or deleted during the build files and reports them to the build log (however such files are not restored by the plugin). The plugin can also ensure that by the start of the build there are no modified or deleted by previous builds files and init clean checkout if such files are detected.

Moreover, Swabra gives the ability to dump processes which lock directory by the end of the build (requires DownloadingHandle)

Swabra can be added as a build feature to your build configuration regardless of what set of build steps you have. By configuring its options you can enable scanning checkout directory for newly created, modified and deleted files and enable file locking processes detection.

Checkout directory state is saved into a file in the caches directory named <checkout_directory_name_hash>.snapshot using DiskDir format. Checkout directory to snapshot name map is saved into snapshot.map file. The snapshot is used later (t the end of the build or at next build start) to determine which files and folders are newly created, modified or deleted. It is done by actual files' presence, last modification data and size comparison with corresponding records in the snapshot.

Configuring Swabra Options



Default excluded paths



If the build is set up to checkout on agent swabra by default ignores all .svn, .git, .hg, CVS folders and their content. To turn off this behaviour specify empty swabra.default.rules configuration parameter.

Downloading Handle



You can download handle.exe from the Administration | Tools page. Select Sysinternals handle.exe from the list of tools, specify URL for downloading handle.exe or download it manually and specify path on local machine, click Continue and TeamCity will automatically download or upload handle.exe and send to Windows agents.

handle.exe is present on agents only after the upgrade process.

You may also download handle.exe, extract it on agent and set up the handle.exe.path system property manually.

Please note that running handle.exe requires some additional permissions for the build agent user. For more details please read this thread.

Debug options



Generally snapshot file is deleted after files collection. Set swabra.preserve.snapshot system property to preserve snapshots for debug purposes.

Development links



See plugin page at Swabra.