Configuration-as-code-plugin: artifactoryBuilder not recognized in unclassified

Created on 29 Apr 2019  路  12Comments  路  Source: jenkinsci/configuration-as-code-plugin

Your checklist for this issue

馃毃 Please review the guidelines for contributing to this repository.

  • [x] Jenkins version 2.164.2

  • [x] Plugin version 1.10.0

  • [x] OS docker jenkins/jenkins:2.164.2-slim (debian)

Description

Jenkins failed to start because of an error with having artifactorybuilder in the unclassified section:

Apr 29, 2019 9:39:38 AM jenkins.InitReactorRunner$1 onTaskFailed
SEVERE: Failed ConfigurationAsCode.init
java.lang.Error: java.lang.reflect.InvocationTargetException
    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:1096)
    at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
    at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:104)
    ... 8 more
Caused by: 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:633)
    at io.jenkins.plugins.casc.ConfigurationAsCode.checkWith(ConfigurationAsCode.java:665)
    at io.jenkins.plugins.casc.ConfigurationAsCode.configureWith(ConfigurationAsCode.java:649)
    at io.jenkins.plugins.casc.ConfigurationAsCode.configureWith(ConfigurationAsCode.java:548)
    at io.jenkins.plugins.casc.ConfigurationAsCode.configure(ConfigurationAsCode.java:277)
    at io.jenkins.plugins.casc.ConfigurationAsCode.init(ConfigurationAsCode.java:269)
    ... 13 more
Caused by: io.jenkins.plugins.casc.ConfiguratorException: Invalid configuration elements for type class jenkins.model.GlobalConfigurationCategory$Unclassified : artifactorybuilder.
Available attributes : administrativeMonitorsConfiguration, ansiColorBuildWrapper, artifactManager, bitbucketEndpointConfiguration, buildStepOperation, casCGlobalConfig, cloud, defaultView, extendedEmailPublisher, gitHubConfiguration, gitHubPluginConfig, gitSCM, globalBuildPromotedBuilds, globalConfigFiles, globalDefaultFlowDurabilityLevel, globalLibraries, httpRequestGlobalConfig, ivyBuildTrigger, ivyModuleSet, jacoco, jiraProjectProperty, location, lockableResourcesManager, mailer, masterBuild, mavenModuleSet, myView, nodeProperties, pipeline-model, plugin, pollSCM, projectNamingStrategy, quietPeriod, rebuildDescriptor, scmRetryCount, shell, sonarGlobalConfiguration, timestamperConfig, upstream, usageStatistics, viewsTabBar
    at io.jenkins.plugins.casc.BaseConfigurator.handleUnknown(BaseConfigurator.java:372)
    at io.jenkins.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:361)
    at io.jenkins.plugins.casc.BaseConfigurator.check(BaseConfigurator.java:282)
    at io.jenkins.plugins.casc.ConfigurationAsCode.lambda$checkWith$6(ConfigurationAsCode.java:665)
    at io.jenkins.plugins.casc.ConfigurationAsCode.invokeWith(ConfigurationAsCode.java:627)
    ... 18 more

If I search for artifactorybuilder in this repo, there is one match showing it under jenkins and two more recent matches showing it under unclassified:
https://github.com/jenkinsci/configuration-as-code-plugin/search?q=artifactorybuilder&unscoped_q=artifactorybuilder

What could cause the error? How can I debug it? Can I use warn instead of reject to only log a warning when Jenkins starts. Thanks.

bug

All 12 comments

Hi @timja . Thanks for the fast response. Can you help me understand the other parts on the CasC side? How to debug it and how to prevent startup failures? Sorry if I am misusing a GH issue for discussing.

Should I remove artifactoryBuilder from my CasC config until the above is fixed? Should we update the examples in this repo with a link to the issue?

It's fine, you need to remove invalid elements.

CasC doesn't allow what it doesn't know about, if you're testing a change do it on an already running jenkins, it won't exit on failure then.

Looking closer, this is most likely to work: https://github.com/jenkinsci/configuration-as-code-plugin/blob/3ef37525f11e1c901031a91b5d2ac8f651c34ee0/demos/artifactory/README.md
but there's a comment saying parts of it doesn't work

The one in the test resources isn't actually tested by anything.

I would suggest nudging here: https://www.jfrog.com/jira/browse/HAP-1018
as JFrog seemed happy to work on it...

In my case, it had been working with artifactorybuilder in the CasC yaml config file. I discovered that a plugins/artifactory.jpi.disabled file was written recently, and with that file present, CasC fails to start up.

Do you have any idea why CasC would behave differently when such a .disabled file is present?

means the plugin is disabled and is not loaded. So, of course, JCasC cannot configure artifactory

But then it is a different issue. Should Jenkins startup fail if we have CasC config for a plugin and we have a plugin.jpi.disabled file at the same time? I would expect at most a warning.

you can try setting:

configuration-as-code:
  unknown: warn

but then you miss the safety of not getting notified when you put a mistake in your config file.

Its there if you do need it for a specific case though

Thanks. Sounds better to me than Jenkins not restarting in case a plugin is disabled via the UI. I also get a nice warning in the /manage UI.

I think this flow is pretty dangerous:

  • Start Jenkins with CasC, for example Artifactory configuration
  • Someone disables the Artifactory plugin via the UI, maybe by accidentally clicking the check box in the plugin list
  • Next time Jenkins is restarted using the same jenkins_home, startup fails

In essense, something in the jenkins_home directory changing behind the back of CasC can make it blow up. I have a hard time understanding why the default is to prevent startup if the configuration is invalid.

Still, thanks for the quick support.

How often do people go disabling plugins in the UI?

In an ideal production setup I would expect:

  • very few people to have access to the UI (if any)
  • all config to be managed through configuration-as-code or groovy scripts if needed for bridging graps
  • plugins changes to be done via promoting tested images, docker or vm images

I do not disagree about the ideal world :)

Was this page helpful?
0 / 5 - 0 ratings