Best practices for removing plugin in containerized Jenkins controller?

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:

  1. Remove plugin(s) from plugins.txt
  2. Rebuild image, deploy
  3. 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.

Short of it, no clear answer here, sorry

There is an open pull request for the Jenkins container repository that is trying to describe the steps to uninstall a plugin

We’d love to have you test drive the description in that pull request and provide feedback on the pull request.

There is also this blog post that could help.