configuration-as-code-plugin icon indicating copy to clipboard operation
configuration-as-code-plugin copied to clipboard

Configuring mvn tool potential issue

Open MadsNielsen opened this issue 8 years ago • 1 comments

I'm having issues configuring a maven tool with configuration as code. The issue seems to be that Configuration-as-Code is confused as to what configurator to use.

We've got this from the configuration: tools

So i started out with just trying to get it to work (Maven installations only require a name)

tool:
  maven:
     installations:
      - name: "myInstallation"

Which gives me:

jenkins_1  | Caused by: java.lang.IllegalArgumentException: Invalid configuration elements for type class jenkins.mvn.GlobalMavenConfig : installations
jenkins_1  | 	at org.jenkinsci.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:200)
jenkins_1  | 	at org.jenkinsci.plugins.casc.DescriptorConfigurator.configure(DescriptorConfigurator.java:45)
jenkins_1  | 	at org.jenkinsci.plugins.casc.DescriptorConfigurator.configure(DescriptorConfigurator.java:12)
jenkins_1  | 	at org.jenkinsci.plugins.casc.BaseConfigurator.configure(BaseConfigurator.java:188)
jenkins_1  | 	at org.jenkinsci.plugins.casc.GlobalConfigurationCategoryConfigurator.configure(GlobalConfigurationCategoryConfigurator.java:45)
jenkins_1  | 	at org.jenkinsci.plugins.casc.ConfigurationAsCode.configureWith(ConfigurationAsCode.java:208)
jenkins_1  | 	... 28 more
jenkins_1  | 

So it seems that Confguration as code tries to configure: https://github.com/jenkinsci/jenkins/blob/08def67a18eee51de9f3f99bc2a792fee1c160e0/core/src/main/java/jenkins/mvn/GlobalMavenConfig.java

While...i think it's supposed to configure: https://github.com/jenkinsci/jenkins/blob/d688c154907d17e75ea31067c8fc2525aa679584/core/src/main/java/hudson/tasks/Maven.java#L666

@ndeloof @oleg-nenashev Are my assumption correct, in that we're configuring the wrong thing via casc?

MadsNielsen avatar Apr 09 '18 10:04 MadsNielsen

Unfortunately GlobalConfiguration use the "tools" category (ToolConfigurationCategory) and as a result is listed here, while Maven task's ToolDescriptor (same "tools" category) declare @Symbol("maven").

Not sure what can be done here to disambiguate. A possible workaround would be for GlobalConfiguration to expose get/setInstallations methods to delegate to Maven. DescriptorImpl

ndeloof avatar Apr 09 '18 11:04 ndeloof