Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-43372

IllegalArgumentException: providerId can NOT be null when using configFiles

      The configFiles context has a bunch of children, each of them has a providerId attribute.
      It's optional, but if you don't specify it you will get the following error at runtime:

      java.lang.IllegalArgumentException: Could not instantiate { ... } for GroovyScript(id: String, name: String, comment: String, content: String, providerId?: String): java.lang.reflect.InvocationTargetException
      	at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:264)
      	at org.jenkinsci.plugins.structs.describable.DescribableModel$instantiate.call(Unknown Source)
      	at javaposse.jobdsl.plugin.structs.DescribableContext.createInstance(DescribableContext.groovy:50)
      	at javaposse.jobdsl.plugin.structs.DescribableContext$createInstance.call(Unknown Source)
      	at javaposse.jobdsl.plugin.structs.DescribableListContext.methodMissing(DescribableListContext.groovy:57)
      	at sun.reflect.GeneratedMethodAccessor15986.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      	at groovy.lang.MetaClassImpl.invokeMissingMethod(MetaClassImpl.java:941)
      	at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1264)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1217)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:812)
      	at javaposse.jobdsl.plugin.structs.DescribableListContext.invokeMethod(DescribableListContext.groovy)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeOnDelegationObjects(ClosureMetaClass.java:430)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:371)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
      	at ConfigFiles$_run_closure1.doCall(ConfigFiles.groovy:9)
      	at ConfigFiles$_run_closure1.doCall(ConfigFiles.groovy)
      	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 org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:57)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
      	at javaposse.jobdsl.dsl.ContextHelper.executeInContext(ContextHelper.groovy:16)
      	at javaposse.jobdsl.dsl.ContextHelper$executeInContext.call(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      	at javaposse.jobdsl.dsl.ContextHelper$executeInContext.call(Unknown Source)
      	at javaposse.jobdsl.plugin.JenkinsJobParent.configFiles(JenkinsJobParent.groovy:18)
      	at javaposse.jobdsl.dsl.DslFactory$configFiles$1.callCurrent(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
      	at ConfigFiles.run(ConfigFiles.groovy:1)
      	at ConfigFiles$run.call(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      	at avalonPipeline$run.call(Unknown Source)
      	at javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScriptEngine(AbstractDslScriptLoader.groovy:111)
      	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 org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:384)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:174)
      	at javaposse.jobdsl.dsl.AbstractDslScriptLoader$_runScripts_closure1.doCall(AbstractDslScriptLoader.groovy:58)
      	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 org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
      	at groovy.lang.Closure.call(Closure.java:414)
      	at groovy.lang.Closure.call(Closure.java:430)
      	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2030)
      	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2015)
      	at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2068)
      	at org.codehaus.groovy.runtime.dgm$164.invoke(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
      	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
      	at javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScripts(AbstractDslScriptLoader.groovy:45)
      	at javaposse.jobdsl.plugin.ExecuteDslScripts.perform(ExecuteDslScripts.java:251)
      	at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:78)
      	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
      	at hudson.model.Build$BuildExecution.build(Build.java:206)
      	at hudson.model.Build$BuildExecution.doRun(Build.java:163)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
      	at hudson.model.Run.execute(Run.java:1728)
      	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      	at hudson.model.ResourceController.execute(ResourceController.java:98)
      	at hudson.model.Executor.run(Executor.java:405)
      Caused by: java.lang.reflect.InvocationTargetException
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      	at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:260)
      	... 89 more
      Caused by: java.lang.IllegalArgumentException: providerId can NOT be null
      	at org.jenkinsci.lib.configprovider.model.Config.<init>(Config.java:94)
      	at org.jenkinsci.plugins.configfiles.groovy.GroovyScript.<init>(GroovyScript.java:48)
      	... 94 more

      This happens for groovy scripts, and xml files. It doesn't seem to happen to maven files.

      Setting the field to any non-null value seems to work.

      I'm guessing (as the field is not visible in the WebUi) this is some internal metadata supposed to idetify where the file came from, so I think job-dsl should supply the actual value there.

          [JENKINS-43372] IllegalArgumentException: providerId can NOT be null when using configFiles

          This seems to be a problem in the config-file-provider plugin. org.jenkinsci.plugins.configfiles.groovy.GroovyScript has a providerId argument in it's DataBoundConstructor but also inherits a DataBoundSetter from org.jenkinsci.lib.configprovider.model.Config. The structs-plugin assumes that it's an optional argument. It would be better if it's either a constructor argument or a setter but not both. And org.jenkinsci.lib.configprovider.model.Config allows providerId to be null when using it's DataBoundConstructor but not when using the constructor with the providerId argument. That is strange.

          Daniel Spilker added a comment - This seems to be a problem in the config-file-provider plugin. org.jenkinsci.plugins.configfiles.groovy.GroovyScript has a providerId argument in it's DataBoundConstructor but also inherits a DataBoundSetter from org.jenkinsci.lib.configprovider.model.Config . The structs-plugin assumes that it's an optional argument. It would be better if it's either a constructor argument or a setter but not both. And org.jenkinsci.lib.configprovider.model.Config allows providerId to be null when using it's DataBoundConstructor but not when using the constructor with the providerId argument. That is strange.

          daspilker thanks for the explanation on how this ended up in generated DSL.

          I still have no idea when one would want to use this (I just put 'job-dsl' there and it works). Is it possible to override some arguments in a generated dsl with preset defaults?

          Jakub Bochenski added a comment - daspilker thanks for the explanation on how this ended up in generated DSL. I still have no idea when one would want to use this (I just put 'job-dsl' there and it works). Is it possible to override some arguments in a generated dsl with preset defaults?

          jbochenski what do you mean by "override some arguments in a generated dsl with preset defaults"?

          Daniel Spilker added a comment - jbochenski what do you mean by "override some arguments in a generated dsl with preset defaults"?

          Jakub Bochenski added a comment - - edited

          daspilker I mean now if I omit the providerId Config constructor will get a null value. Would it be possible to change the behavior on the job-dsl level and pass an empty string instead of a null if the value isn't specified in groovy.

          Jakub Bochenski added a comment - - edited daspilker I mean now if I omit the providerId Config constructor will get a null value. Would it be possible to change the behavior on the job-dsl level and pass an empty string instead of a null if the value isn't specified in groovy.

          jbochenski that's not possible. Job DSL does not make any assumption about generated DSL. IMHO that should be fixed in config-file-provider. We need to wait for domi to comment on this.

          Daniel Spilker added a comment - jbochenski that's not possible. Job DSL does not make any assumption about generated DSL. IMHO that should be fixed in config-file-provider. We need to wait for domi to comment on this.

          Daniel Spilker added a comment - I opened a PR for config-file-provider: https://github.com/jenkinsci/config-file-provider-plugin/pull/39

          Code changed in jenkins
          User: Daniel Spilker
          Path:
          src/main/java/org/jenkinsci/plugins/configfiles/custom/CustomConfig.java
          src/main/java/org/jenkinsci/plugins/configfiles/groovy/GroovyScript.java
          src/main/java/org/jenkinsci/plugins/configfiles/json/JsonConfig.java
          src/main/java/org/jenkinsci/plugins/configfiles/maven/MavenToolchainsConfig.java
          src/main/java/org/jenkinsci/plugins/configfiles/xml/XmlConfig.java
          http://jenkins-ci.org/commit/config-file-provider-plugin/e745ca0eeec2621c7d0f0ed44ee3fc55959be6d9
          Log:
          use inherited @DataBoundSetter for providerId

          [FIXES JENKINS-43372]

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Daniel Spilker Path: src/main/java/org/jenkinsci/plugins/configfiles/custom/CustomConfig.java src/main/java/org/jenkinsci/plugins/configfiles/groovy/GroovyScript.java src/main/java/org/jenkinsci/plugins/configfiles/json/JsonConfig.java src/main/java/org/jenkinsci/plugins/configfiles/maven/MavenToolchainsConfig.java src/main/java/org/jenkinsci/plugins/configfiles/xml/XmlConfig.java http://jenkins-ci.org/commit/config-file-provider-plugin/e745ca0eeec2621c7d0f0ed44ee3fc55959be6d9 Log: use inherited @DataBoundSetter for providerId [FIXES JENKINS-43372]

          Code changed in jenkins
          User: Dominik Bartholdi
          Path:
          src/main/java/org/jenkinsci/plugins/configfiles/custom/CustomConfig.java
          src/main/java/org/jenkinsci/plugins/configfiles/groovy/GroovyScript.java
          src/main/java/org/jenkinsci/plugins/configfiles/json/JsonConfig.java
          src/main/java/org/jenkinsci/plugins/configfiles/maven/MavenToolchainsConfig.java
          src/main/java/org/jenkinsci/plugins/configfiles/xml/XmlConfig.java
          http://jenkins-ci.org/commit/config-file-provider-plugin/97ba2549540d16537315c72e5eed65304263cd31
          Log:
          Merge pull request #39 from daspilker/JENKINS-43372

          JENKINS-43372 use inherited @DataBoundSetter for providerId

          Compare: https://github.com/jenkinsci/config-file-provider-plugin/compare/b8d2caa18607...97ba2549540d

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Dominik Bartholdi Path: src/main/java/org/jenkinsci/plugins/configfiles/custom/CustomConfig.java src/main/java/org/jenkinsci/plugins/configfiles/groovy/GroovyScript.java src/main/java/org/jenkinsci/plugins/configfiles/json/JsonConfig.java src/main/java/org/jenkinsci/plugins/configfiles/maven/MavenToolchainsConfig.java src/main/java/org/jenkinsci/plugins/configfiles/xml/XmlConfig.java http://jenkins-ci.org/commit/config-file-provider-plugin/97ba2549540d16537315c72e5eed65304263cd31 Log: Merge pull request #39 from daspilker/ JENKINS-43372 JENKINS-43372 use inherited @DataBoundSetter for providerId Compare: https://github.com/jenkinsci/config-file-provider-plugin/compare/b8d2caa18607...97ba2549540d

            domi Dominik Bartholdi
            jbochenski Jakub Bochenski
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: