Run a custom PowerShell script when retention policies apply to a package
When Tentacle cleans up an installed package folder as part of retention policies, it would be great to be able to have a custom script - like "Undeploy.ps1" - which Tentacle invokes if it finds.
This would make it possible to delete old custom installation folders during deployment.

-
Dan Fiedler commented
Removing IIS sites/apps/v-dirs as part of this would also be great for release per branch
-
Josh Michielsen commented
This would be very helpful!
-
Mark commented
It looks like it would be easy to extend https://github.com/OctopusDeploy/Calamari/blob/master/source/Calamari/Deployment/Retention/RetentionPolicy.cs to purge the CustomInstallationDirectory folder on each deployment entry in the journal.
-
Sohail commented
it would be great if old releases form the custom install folder can be deleted, basically the retention policy being applied to custom directories. For me this is one big thing missing other then that octopus is awesome.
-
Sam “Betty” McKoy commented
Potentially custom Triggers (like the release triggers in 3.4)?
-
Sam “Betty” McKoy commented
This would be great for cleaning up after release per branch scenarios.
Needs to take channels into consideration (probably life cycles/environments in general)
Also wonder if it makes sense to be a octopus task list instead of script
-
Chris Gaskell commented
Hey,
I use this post deploy script to help with that ->
$keep = $OctopusParameters["ReleaseVersionsToKeep"]
$releaseFolders = Get-ChildItem $OctopusParameters["PathPrefix"] | Where-Object {$_.name -like "1.0*"}
if ($releaseFolders.Count -gt $keep) {
$releaseFolders | Sort-Object CreationTime | Select-Object -First ($releaseFolders.Count - $keep) | Remove-Item -Force -recurse
}Thanks
Chris
-
Ranjith Zachariah commented
Upvote!
I encountered this problem in my Octopus setup. I have a Custom Installation directory of
C:\IMS\#{Octopus.Release.Number}
I also have a rentention policy of 3 releases on my project group. This retention policy is not being respected by my Tentacles.
Sad face.