[JIRA] (JENKINS-60045) JCasC export doesn't work with Custom Tools installed and configured

0 views
Skip to first unread message

timothy.rheault@carlsonwagonlit.com (JIRA)

unread,
Nov 4, 2019, 12:29:03 PM11/4/19
to jenkinsc...@googlegroups.com
TJ Rue created an issue
 
Jenkins / Bug JENKINS-60045
JCasC export doesn't work with Custom Tools installed and configured
Issue Type: Bug Bug
Assignee: Ewelina Wilkosz
Components: configuration-as-code-plugin, customtools-plugin
Created: 2019-11-04 17:28
Environment: QA
Priority: Minor Minor
Reporter: TJ Rue

When the Custom Tools plugin is installed and a Custom Tool is configured and JCasc 'View Configuration' button is clicked and the following error results in the Casc output:

```customTool:
installations: |-
FAILED TO EXPORT
com.cloudbees.jenkins.plugins.customtools.CustomTool$DescriptorImpl#installations: java.lang.IllegalArgumentException: argument type mismatch
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)```

 

I attempted this with the following versions:

Configuration as Code Plugin version 1.32
Configuration as Code Support Plugin version 1.19
Custom Tools version .6
Jenkins version 2.190.1

 

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

Kalle.Niemitalo@procomp.fi (JIRA)

unread,
Dec 2, 2019, 9:02:04 AM12/2/19
to jenkinsc...@googlegroups.com
Kalle Niemitalo commented on Bug JENKINS-60045
 
Re: JCasC export doesn't work with Custom Tools installed and configured

FWIW, the syntax for configuring custom tools via JCasC appears to be like this:

tool:
  customTool:
    installations:
    - name: "DocFx"
      home: ""
      properties:
      - installSource:
          installers:
          - zip:
              label: "windows"
              url: "https://github.com/dotnet/docfx/releases/download/v2.39.2/docfx.zip"

Kalle.Niemitalo@procomp.fi (JIRA)

unread,
Dec 2, 2019, 12:16:05 PM12/2/19
to jenkinsc...@googlegroups.com

The whole stack trace from Jenkins 2.190.3, Configuration as Code Plugin 0.7, Configuration as Code Plugin 1.34, Configuration as Code Support not installed:

FAILED TO EXPORT
com.cloudbees.jenkins.plugins.customtools.CustomTool$DescriptorImpl#installations: java.lang.IllegalArgumentException: argument type mismatch
  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 io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.describe(DataBoundConfigurator.java:299)
  at io.jenkins.plugins.casc.Attribute._describe(Attribute.java:264)
  at io.jenkins.plugins.casc.Attribute.describe(Attribute.java:239)
  at io.jenkins.plugins.casc.Configurator.describe(Configurator.java:162)
  at io.jenkins.plugins.casc.impl.configurators.GlobalConfigurationCategoryConfigurator.describe(GlobalConfigurationCategoryConfigurator.java:106)
  at io.jenkins.plugins.casc.impl.configurators.GlobalConfigurationCategoryConfigurator.lambda$describe$3(GlobalConfigurationCategoryConfigurator.java:99)
  at io.jenkins.plugins.casc.impl.configurators.GlobalConfigurationCategoryConfigurator$$Lambda$286.0000000000000000.accept(Unknown Source)
  at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
  at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
  at java.util.Iterator.forEachRemaining(Iterator.java:116)
  at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
  at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:497)
  at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:487)
  at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
  at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
  at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:241)
  at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:485)
  at io.jenkins.plugins.casc.impl.configurators.GlobalConfigurationCategoryConfigurator.describe(GlobalConfigurationCategoryConfigurator.java:99)
  at io.jenkins.plugins.casc.impl.configurators.GlobalConfigurationCategoryConfigurator.describe(GlobalConfigurationCategoryConfigurator.java:30)

Kalle.Niemitalo@procomp.fi (JIRA)

unread,
Dec 2, 2019, 1:20:02 PM12/2/19
to jenkinsc...@googlegroups.com
Kalle Niemitalo edited a comment on Bug JENKINS-60045
The whole A longer stack trace from Jenkins 2.190.3, Configuration as Code Custom Tools Plugin 0.7, Configuration as Code Plugin 1.34, Configuration as Code Support not installed:

{noformat}
{noformat}

Kalle.Niemitalo@procomp.fi (JIRA)

unread,
Dec 2, 2019, 1:23:03 PM12/2/19
to jenkinsc...@googlegroups.com

I wonder if the error is triggered by com.cloudbees.jenkins.plugins.customtools.CustomTool$DescriptorImpl overriding setInstallations with a concrete type but not getInstallations.  Might be related to this comment in io.jenkins.plugins.casc.BaseConfigurator#describe:

        // Resolve the methods and merging overrides to more concretized signatures
        // because the methods can to have been overridden with concretized type
        // TODO: Overloaded setters with different types can corrupt this logic

Kalle.Niemitalo@procomp.fi (JIRA)

unread,
Dec 3, 2019, 5:19:03 AM12/3/19
to jenkinsc...@googlegroups.com

The exception was thrown during the newInstance call at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.describe(DataBoundConfigurator.java:299):

T ref = (T) constructor.newInstance(args);

The type being constructed should be CustomTool, and I think it is. If the type had been CustomTool[] or ToolInstallation[] or ToolInstallation, then DataBoundConfigurator.getDataBoundConstructor would have returned null, and DefaultConfiguratorRegistry.internalLookup would not have created an instance of DataBoundConfigurator.

So, it seems to be a matter of incorrect arguments being generated for the CustomTool constructor.

Perhaps the error is triggered by the @CheckForNull LabelSpecifics[] labelSpecifics parameter of that constructor. If CustomTool.getLabelSpecifics returns an empty array, then the type of this array does not implement java.util.Collection, so DataBoundConfiguration.describe assigns args[i] = Collections.singletonList(converted), which is not acceptable to the constructor.

If this theory is correct, then the error could be fixed either by changing CustomTool to use a collection type instead of the array type, or by changing DataBoundConfiguration to check for array types as well. I cannot currently test these changes myself.

Kalle.Niemitalo@procomp.fi (JIRA)

unread,
Dec 3, 2019, 5:22:04 AM12/3/19
to jenkinsc...@googlegroups.com
Kalle Niemitalo edited a comment on Bug JENKINS-60045
The exception was thrown during the {{newInstance}} call at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.describe([DataBoundConfigurator.java:299|https://github.com/jenkinsci/configuration-as-code-plugin/blob/c0528a7b412fd83908f2ef2ce5c32d2bb499823d/plugin/src/main/java/io/jenkins/plugins/casc/impl/configurators/DataBoundConfigurator.java#L299]):

{code:java}

T ref = (T) constructor.newInstance(args);
{code}

The type being constructed should be {{CustomTool}}, and I think it is. If the type had been {{CustomTool[]}} or {{ToolInstallation[]}} or {{ToolInstallation}}, then {{DataBoundConfigurator.getDataBoundConstructor}} would have returned null, and {{DefaultConfiguratorRegistry.internalLookup}} would not have created an instance of {{DataBoundConfigurator}}.

So, it seems to be a matter of incorrect arguments being generated for the [{{CustomTool}} constructor|https://github.com/jenkinsci/custom-tools-plugin/blob/28152af024c2e5a3e46b02a3b185869488d3a6e4/src/main/java/com/cloudbees/jenkins/plugins/customtools/CustomTool.java#L94-L104].

Perhaps the error is triggered by the {{@CheckForNull LabelSpecifics[] labelSpecifics}} parameter of that constructor. If [{{CustomTool.getLabelSpecifics}}|https://github.com/jenkinsci/custom-tools-plugin/blob/28152af024c2e5a3e46b02a3b185869488d3a6e4/src/main/java/com/cloudbees/jenkins/plugins/customtools/CustomTool.java#L132-L134] returns an
empty array, then the type of this array does not implement {{java.util.Collection}}, so {{DataBoundConfiguration.describe}} assigns {{args[i] = Collections.singletonList(converted)}}, which is not acceptable to the constructor.


If this theory is correct, then the error could be fixed either by changing {{CustomTool}} to use a collection type instead of the array type, or by changing {{DataBoundConfiguration}} to check for array types as well. I cannot currently test these changes myself.

Kalle.Niemitalo@procomp.fi (JIRA)

unread,
Dec 3, 2019, 6:19:08 AM12/3/19
to jenkinsc...@googlegroups.com
Kalle Niemitalo edited a comment on Bug JENKINS-60045
The exception was thrown during the {{newInstance}} call at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.describe([DataBoundConfigurator.java:299|https://github.com/jenkinsci/configuration-as-code-plugin/blob/c0528a7b412fd83908f2ef2ce5c32d2bb499823d/plugin/src/main/java/io/jenkins/plugins/casc/impl/configurators/DataBoundConfigurator.java#L299]):

{code:java}
T ref = (T) constructor.newInstance(args);
{code}

The type being constructed should be {{CustomTool}}, and I think it is. If the type had been {{CustomTool[]}} or {{ToolInstallation[]}} or {{ToolInstallation}}, then {{DataBoundConfigurator.getDataBoundConstructor}} would have returned null, and {{DefaultConfiguratorRegistry.internalLookup}} would not have created an instance of {{DataBoundConfigurator}}.

So, it seems to be a matter of incorrect arguments being generated for the [{{CustomTool}} constructor|https://github.com/jenkinsci/custom-tools-plugin/blob/28152af024c2e5a3e46b02a3b185869488d3a6e4/src/main/java/com/cloudbees/jenkins/plugins/customtools/CustomTool.java#L94-L104].

Perhaps the error is triggered by the {{@CheckForNull LabelSpecifics[] labelSpecifics}} parameter of that constructor. If [{{CustomTool.getLabelSpecifics}}|https://github.com/jenkinsci/custom-tools-plugin/blob/28152af024c2e5a3e46b02a3b185869488d3a6e4/src/main/java/com/cloudbees/jenkins/plugins/customtools/CustomTool.java#L132-L134] returns an array, then the type of this array does not implement {{java.util.Collection}}, so {{DataBoundConfiguration.describe}} assigns {{args[i] = Collections.singletonList(converted)}}, which is not acceptable to the constructor.

If this theory is correct, then the error could be fixed either by changing {{CustomTool}} to use a collection type instead of the array type, or by changing {{
DataBoundConfiguration DataBoundConfigurator }} to check for array types as well. I cannot currently test these changes myself.

Kalle.Niemitalo@procomp.fi (JIRA)

unread,
Dec 4, 2019, 3:45:03 AM12/4/19
to jenkinsc...@googlegroups.com

Kalle.Niemitalo@procomp.fi (JIRA)

unread,
Jan 12, 2020, 4:46:04 PM1/12/20
to jenkinsc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages