We are currently building our Jenkins controller via CASC and a plugins.txt to feed plugin versions as tracked in source control. One question I have with this process, what is the best method to manage the removal of plugins when something is deprecated or otherwise needs to be removed?
As of now, I would probably:
Remove plugin(s) from plugins.txt
Rebuild image, deploy
Remove plugin(s) via the UI and restart
Obviously not ideal from an effort perspective.
I do see a recommendation to modify the controller to purge the plugins dir at startup to force a re-configuration of the container-supplied plugins.
I assume in this case your jenkins is in the container, but the home directory is on a separate volume. Since plugins and their configuration are in the home directory, changes to the container do not really affect it and, in my experience, CasC does not remove plugins, only adds/upgrades them (not sure if this is true though). Until CasC supports removal of plugins, your best bet is to remove from CasC AND disable (rather than remove) in UI. Removing in UI is better, but requires a restart.
You can also, as suggested, write something that will nuke the plugins directory on startup, but then you will be reinstalling everything every time.