Don't let unknown keywords stop Jenkins startup
See original GitHub issueYour checklist for this issue
- Jenkins version - 2,83
- Plugin version - 1.47
- OS - Ubuntu 20.04, x86_64, openjdk-11-jre-headless:amd64
Description
After I removed a plugin (Stash Pull Request Builder) and restarted Jenkins, the top level Jenkins URL showed a page with a stack trace:
io.jenkins.plugins.casc.ConfiguratorException: Invalid configuration elements for type class jenkins.model.GlobalConfigurationCategory$Unclassified : stashBuildTrigger.
Available attributes : administrativeMonitorsConfiguration, artifactManager, bitbucketEndpointConfiguration, buildDiscarders, casCGlobalConfig, defaultFolderConfiguration, defaultView, email-ext, envVarsFilter, fingerprints, gitHubConfiguration, gitHubPluginConfig, gitSCM, globalConfigFiles, globalDefaultFlowDurabilityLevel, globalLibraries, jiraGlobalConfiguration, junitTestResultStorage, location, lockableResourcesManager, mailer, masterBuild, myView, nodeProperties, pipeline-model-docker, plugin, pollSCM, projectNamingStrategy, quietPeriod, resourceRoot, scmRetryCount, shell, timestamper, usageStatistics, viewsTabBar
at io.jenkins.plugins.casc.BaseConfigurator.handleUnknown(BaseConfigurator.java:376)
at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:365)
at io.jenkins.plugins.casc.BaseConfigurator.check(BaseConfigurator.java:287)
at io.jenkins.plugins.casc.ConfigurationAsCode.lambda$checkWith$8(ConfigurationAsCode.java:753)
at io.jenkins.plugins.casc.ConfigurationAsCode.invokeWith(ConfigurationAsCode.java:689)
Caused: io.jenkins.plugins.casc.ConfiguratorException: unclassified: error configuring 'unclassified' with class io.jenkins.plugins.casc.impl.configurators.GlobalConfigurationCategoryConfigurator configurator
at io.jenkins.plugins.casc.ConfigurationAsCode.invokeWith(ConfigurationAsCode.java:695)
at io.jenkins.plugins.casc.ConfigurationAsCode.checkWith(ConfigurationAsCode.java:753)
at io.jenkins.plugins.casc.ConfigurationAsCode.configureWith(ConfigurationAsCode.java:738)
at io.jenkins.plugins.casc.ConfigurationAsCode.configureWith(ConfigurationAsCode.java:614)
at io.jenkins.plugins.casc.ConfigurationAsCode.configure(ConfigurationAsCode.java:298)
at io.jenkins.plugins.casc.ConfigurationAsCode.init(ConfigurationAsCode.java:290)
Caused: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:104)
Caused: java.lang.Error
at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:110)
at hudson.init.TaskMethodFinder$TaskImpl.run(TaskMethodFinder.java:175)
at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
at jenkins.model.Jenkins$5.runTask(Jenkins.java:1130)
at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused: org.jvnet.hudson.reactor.ReactorException
at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:282)
at jenkins.InitReactorRunner.run(InitReactorRunner.java:49)
at jenkins.model.Jenkins.executeReactor(Jenkins.java:1163)
at jenkins.model.Jenkins.<init>(Jenkins.java:961)
at hudson.model.Hudson.<init>(Hudson.java:85)
at hudson.model.Hudson.<init>(Hudson.java:81)
at hudson.WebAppMain$3.run(WebAppMain.java:295)
Caused: hudson.util.HudsonFailedToLoad
at hudson.WebAppMain$3.run(WebAppMain.java:312)
I could upload the config without “stashBuildTrigger”, but I had to log in to the Jenkins system to restart it. The URL with “/safeRestart” would just show the same stack trace.
I believe it would be much better if the Configuration ad Code Plugin would just record the issue and continue. There are other ways to alert the user of obsolete parts of the configuration. It’s possible to log an error and show it in the administrative monitor.
The issue is not new, I hit it a few times in the past.
Removing plugins should not be a minefield. Jenkins itself is much more gracious when some code is missing to handle the a configuration file.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:9 (4 by maintainers)
Top GitHub Comments
I see no reason to change the default behavior. User is free to change them at anytime. You ought to have a test instance or a dev setup where you can apply changes before breaking the production setup. It is good practice to know the necessary steps ahead of time.
The way we use JCASC may be different but again JCASC is an opinionated way of how to run your Jenkins instance.
WDYT @oleg-nenashev @timja
@proski You can configure this. 😃 Although I disagree with the option, removing a plugin should remind you that you have unused config. Perhaps setup a docker test instance for maintaining a working copy before applying changes?
https://github.com/jenkinsci/configuration-as-code-plugin/blob/25b26febfc4aa01ec0abde0295763475f7ffee4b/test-harness/src/test/resources/io/jenkins/plugins/casc/validSelfConfig.yml
https://github.com/jenkinsci/configuration-as-code-plugin/blob/223ac074c0dec8e6c5812acefd02c97c518a3903/plugin/src/main/java/io/jenkins/plugins/casc/ConfigurationContext.java#L171-L184