Upgrade Groovy jenkins plugin

How can I upgrade plugin groovy 2 to groovy 3?

Groovy can’t be upgraded from groovy 2 to groovy 3 inside Jenkins without significant work in multiple locations. It will need a coordinated effort across multiple components to perform that upgrade.

See the series of epics for more details:

Those steps are describing the Groovy version that is included inside Jenkins. That does not stop you from using Groovy 3 or Groovy 4 in your Jenkins jobs.

Using Groovy 3 or Groovy 4 in a Jenkins job

If you need to run a standalone Groovy 3 or Groovy 4 script, you can call it from a Jenkins Pipeline (sh or bat or powershell) with your preferred groovy command line. Darin Pope has created a video that shows how to do that.