Interview Prep/CI/CD/Jenkins Credentials, Plugins and Controller Issues

`java.lang.IllegalStateException: Jenkins.instance is missing` in a plugin or script.

AdvancedTroubleshootingJenkins Credentials, Plugins and Controller Issues
Answer

Likely causes → Code runs on an agent JVM instead of the controller, or Jenkins is shutting down.

Diagnose → Check where the code executes (inside a node block vs controller).

Fix → Move controller-API calls into @NonCPS library code running on the controller, not inside an agent-side closure.

Prevent → Avoid direct Jenkins.instance in pipelines.

All CI/CD questions

More on Jenkins Credentials, Plugins and Controller Issues