Deploy a package step with custom install directory has purge option but is their a way to purge and keep just one folder?

Through the “deploy a package” step template their is a custom feature called “custom install directory” that has a purge option you can select which will clear the install directory before the install. I am needing to purge everything except one folder. Is their any variables besides true/false here that can be entered to purge everything except for a single folder ?

Hi,

Thanks for getting in touch! While there’s no variable or feature which will allow you to prevent a folder in your custom install directory from being purged, this is possible using a custom script.

If you use a custom variable with your installation directory value in it, you can script which files are removed from that directory before package extraction in a predeploy script. You can define a predeploy script in your package step by selecting the Custom deployment scripts option. You can refer to more info in our custom scripts documentation page: https://octopus.com/docs/deploying-applications/custom-scripts#Customscripts-Scriptsinpackagestepsscripts-configured-in-steps

As far as an enhancement to allow exclusion rules for the directory purging, we have an open GitHub issue to address this which you can track here: https://github.com/OctopusDeploy/Issues/issues/2943

I hope this helps! Let me know if you have any further questions.

Best regards,

Kenny

Hi,

I just want to update you to let you know that we have released the enhancement that allows you to define exclusion rules when purging your custom install directory. It has been added to the latest version (3.13.8), and I’ve attached a screenshot showing how it looks :slight_smile:

Don’t hesitate to reach out if you have any further questions.

Best regards,

Kenny

I did the pre-deploy script and it worked great. Very good on the new purge feature this is going to be great. I plan on upgrading later in June to the latest package so we’ll get this then. Thanks.

Hi,

That’s no problem at all. That’s great to hear your pre-deploy script is working for this. :slight_smile:

Don’t hesitate to reach out anytime if you have any further questions.

Best regards,

Kenny

Hi,

great feature but the field “Exclude from purge” is removed/hidden if you switch to a variable for the Purge option.
The system is not able to check if the variable is true or false then hide the filed.
Ex: in purge, set as #{PurgeFiles}

Sébastien

Hi Sebastien,

Thanks for following up and pointing this out. I’ve been able to reproduce this bug. The functionality still works, so if you have your exclusion rules already saved in the step, and re-edit it to input a variable for the Purge option (to set the true or false value in the deployment), the variable will still resolve to the value that is expected. I’ve raised the following issue to get this resolved which you can track: https://github.com/OctopusDeploy/Issues/issues/3542

Thanks again, and let me know if you have any further questions.

Best regards,

Kenny