Get Release Number of deployment being cleaned by the Retention Policy

We have several custom items (databases, folders, backups) that are created during a deployment that need to be cleaned up. They all use the Release Version number and we would like to use the Retention Policy to remove them. If we can get the release number that Octopus (or the Tentacle?) is cleaning we can create the steps necessary to clean up our custom items. Or if we can get a list of successful deployments for the machine currently being deployed, we can calculate which items need to be removed.

Any help is appreciated.


Thanks for reaching out! On each Tentacle there’s a file called DeploymentJournal that contains all the info of the releases that were deployed to that Tentacle, along with the paths where we dropped the code. Its the file we use for the Retention Policy logic.

That would be your best bet for this. You can find it by default under: C:\Octopus\DeploymentJournal.xml


Thanks for the info! Is there a variable or some way to get the path of that file inside a step? The installation location varies on our machines.

Senior Software Engineer

NISH TECH, INC. | www.nishtechinc.com

You can use $env:TentacleApplications from a Powershell script or #{env:TentacleApplications} from an Octopus field to get the parent path (e.g *C:\Octopus*)

That variable shoudl give you the right path on each Tentacle it runs.


That is awesome! Thanks!