Clean Working Folder after Build

Hi

How would I automate the cleaning (e.g. deleting) of the contents of the working folder once a build has completed?

Please provide examples, thanks.

8 comments
Comment actions Permalink

If you are using TeamCity 6.0, probably "Swabra build feature" will be of some help: http://confluence.jetbrains.net/display/TCD6/Adding+Swabra+as+a+Build+Feature

Swabra also available as a separate plugin: http://confluence.jetbrains.net/display/TW/Swabra

0
Comment actions Permalink

Thanks Pavel

Yes, we are using v6.

But as far as I can see, the new Swabra feature only deletes files that were produced by the build process.

Whereas I would like to delete *all* files.. e.g. the onces checked out of source control as well.

0
Comment actions Permalink

What about adding a build step which will clean all of the files in checkout directory?

0
Comment actions Permalink

Sounds like an interesting idea.

What command exactly would do that?

0
Comment actions Permalink

I think this will work on windows:
del /F .
On Linux:
rm -rf *

But you should be very careful, especially if agent is installed on the same PC where server is running. Under some circumstances such commands can wipe all your data.

0
Comment actions Permalink

OK, if I create a build step with this configuration:

Runner type: Command Line

Working directory: E:\TeamCity\MyApplication\Release

Run: Executable with Parameters

Command executable: del

Command parameters: /F /Q .

Will it wipe all my data or just the build data and source code?

0
Comment actions Permalink

It will wipe everything under the working directory. But if someone will change the working directory to C:\Windows or smthg like that...
It is much safer to have such agents running from the VMWare images, because in this case you can easily recreate agent environment.

0

Please sign in to leave a comment.