deleting files on agent, when a build is deleted

Maybe I'm missing something, but currently when I delete a project it's checkout directory is not deleted on the agents.
In addition we would not only like to delete the checkout dir but some more files which are created by our builds in other directorys (say the 'working dir', which is one level up the checkout dir).

Are there any means how I could do that by configuration (kicking some ant target would be all we needed).

Or should we write a custom plugin? We did that already for the serverside, but I can't get a clue, who this would be done on agents ?
How could I get notified about a build delete and how could I retrieve the working dir ?

1 comment

Hello,
TeamCity build agents stores all it's files inside work\directories.map
file. All listed directories are cleaned if there was no activity for defined
timeout time. That time can be set on agent using buildAgent.properties file
or as build configuration property. But, actually that will not work for
you is there are some build directories that is not configured in Build Configuration.

As a workaround, consider creating several fake build configurations without
VCS, but with working folders set to the additional directories that have
to be cleaned up. Settings those configurations to be triggered on the finish
of the main configuration should work as the workaround, but, this will produce
some mass in the queue.
Please note, for build configurations with custom working folders you will
have to specify expiration timeout manually in the build configuration.

For settings timeouts:
- on build agent define property 'teamcity.agent.build.checkoutDir.expireHours'
with value in hours
- for the build configuration, define system property 'teamcity.build.checkoutDir.expireHours'
the value should be in hours. Actually, you will have to patch build configuration
file, because there is no way to define from the Web interface any property
not staring from 'system.'.

The other way is to patch directories.map file. I recomend doing it when
build agent is shut down.

As for server side. To be nofitied on the events related to build configuration
deletion, please have a look to

jetbrains.buildServer.serverSide.BuildServerListener#buildTypeUnregistered(SBuildType
buildType)
and
jetbrains.buildServer.serverSide.BuildServerListener#buildTypeRegistered(SBuildType
buildType)

Please, note, those methods are called if build configuration is unloaded.
There is no easy way to realize if it happened because of configuration reload
or because of it was really removed or because some other reason. The right
way is to wait for a while to receive buildTypeRegistered. Server shutdown
could happen between those notifications. Actually, it is a complicated way.
For that case, the second part will be to register some plugin on the agent-side
to receive the notification form server-plugin. Please fill free to ask me
for details on that.

The last idea is to create some sort of maintanace build configurations that
can clear all necessary directories on the agent. You can trigger it either
from Web or from serverside api.

Thanks! Hope this helps.

--
Eugene Petrenko
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Maybe I'm missing something, but currently when I delete a project
it's checkout directory is not deleted on the agents.

In addition we would not only like to delete the checkout dir but some
more files which are created by our builds in other directorys (say
the 'working dir', which is one level up the checkout dir).

Are there any means how I could do that by configuration (kicking some
ant target would be all we needed).

Or should we write a custom plugin? We did that already for the
serverside, but I can't get a clue, who this would be done on agents ?

How could I get notified about a build delete and how could I retrieve
the working dir ?



0

Please sign in to leave a comment.