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

Perforce plugin: JCasC cannot export configuration

    Details

    • Similar Issues:

      Description

      If P4 credentials are configured, then JCasC fails to export Jenkins configuration with an error:

      FAILED TO EXPORT com.cloudbees.plugins.credentials.domains.DomainCredentials#credentials: 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:255)
      at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.lambda$convertToNode$de0cd4f8$1(HeteroDescribableConfigurator.java:224)
      at io.vavr.CheckedFunction0.lambda$unchecked$52349c75$1(CheckedFunction0.java:201)
      at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.convertToNode(HeteroDescribableConfigurator.java:224)
      at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.lambda$describe$5(HeteroDescribableConfigurator.java:103)
      at io.vavr.control.Option.map(Option.java:373)
      at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.describe(HeteroDescribableConfigurator.java:103)
      at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.describe(HeteroDescribableConfigurator.java:51)
      at io.jenkins.plugins.casc.Attribute.describe(Attribute.java:194)
      at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.describe(DataBoundConfigurator.java:264)
      at io.jenkins.plugins.casc.Attribute.describe(Attribute.java:194)
      at com.cloudbees.plugins.credentials.casc.SystemCredentialsProviderConfigurator.describe(SystemCredentialsProviderConfigurator.java:76)
      at com.cloudbees.plugins.credentials.casc.SystemCredentialsProviderConfigurator.describe(SystemCredentialsProviderConfigurator.java:48)
      at io.jenkins.plugins.casc.Attribute.describe(Attribute.java:198)
      at com.cloudbees.plugins.credentials.casc.CredentialsRootConfigurator.describe(CredentialsRootConfigurator.java:90)
      at com.cloudbees.plugins.credentials.casc.CredentialsRootConfigurator.describe(CredentialsRootConfigurator.java:52)

        Attachments

          Activity

          Hide
          casz Joseph Petersen (old) added a comment -

          After reading your post and looking at the code, I'd suggest the best fix is located in p4 plugin as it clearly does not follow Java Bean conventions.

          Show
          casz Joseph Petersen (old) added a comment - After reading your post and looking at the code, I'd suggest the best fix is located in p4 plugin as it clearly does not follow Java Bean conventions.
          Hide
          p4paul Paul Allen added a comment - - edited

          Sorry for not looking at this sooner. As suggested I have added a getSsl() method into the Perforce Base Credentials.  I have manually tested this against the configuration-as-code plugin with a Perforce SSL connection and it looks good to me.

          Please let me know if you are able to verify this fix and confirm there are no side effects when using SSL enabled Perforce Servers.

          https://ci.jenkins.io/job/Plugins/job/p4-plugin/job/master/434/

          Show
          p4paul Paul Allen added a comment - - edited Sorry for not looking at this sooner. As suggested I have added a getSsl() method into the Perforce Base Credentials.  I have manually tested this against the configuration-as-code plugin with a Perforce SSL connection and it looks good to me. Please let me know if you are able to verify this fix and confirm there are no side effects when using SSL enabled Perforce Servers. https://ci.jenkins.io/job/Plugins/job/p4-plugin/job/master/434/
          Hide
          drodspike David Rodriguez added a comment -

          Hi Paul,

          Would like to test this fix but I need to some help on how to configure the JCasC jenkins.yaml file for the P4 credential.   

          Below  is my attempt to add P4 credential to the jenkins.yaml file  and restart jenkins.  Getting  stacktrace :

          java.lang.IllegalArgumentException: No com.cloudbees.plugins.credentials.Credentials implementation found for P4BaseCredentials"

          // code placeholder
          
          credentials:
            system:
              domainCredentials:
              - credentials:
                - basicSSHUserPrivateKey:
                    description: "Private key credentials for Jenkins GitLab user"
                    id: "gitlab-key"
                    privateKeySource:
                      directEntry:
                        privateKey: ${GITLAB_PRIVATE_KEY}
                    scope: GLOBAL
                    username: ${JENKINS_GITLAB_USER_NAME}
               - P4BaseCredentials:
                    description: "Perforce password credential"
                    id: "p4-userpass"
                    p4port: "${PERFORCE_SERVER}:${PERFORCE_PORT}"
                    scope: GLOBAL
                    username: ${PERFORCE_USER_NAME}
                    password: ${PERFORCE_PASSWORD}

           

           

           

          Show
          drodspike David Rodriguez added a comment - Hi Paul, Would like to test this fix but I need to some help on how to configure the JCasC jenkins.yaml file for the P4 credential.    Below  is my attempt to add P4 credential to the jenkins.yaml file  and restart jenkins.  Getting  stacktrace : java.lang.IllegalArgumentException: No com.cloudbees.plugins.credentials.Credentials implementation found for P4BaseCredentials" // code placeholder credentials: system: domainCredentials: - credentials: - basicSSHUserPrivateKey: description: "Private key credentials for Jenkins GitLab user" id: "gitlab-key" privateKeySource: directEntry: privateKey: ${GITLAB_PRIVATE_KEY} scope: GLOBAL username: ${JENKINS_GITLAB_USER_NAME} - P4BaseCredentials: description: "Perforce password credential" id: "p4-userpass" p4port: "${PERFORCE_SERVER}:${PERFORCE_PORT}" scope: GLOBAL username: ${PERFORCE_USER_NAME} password: ${PERFORCE_PASSWORD}      
          Hide
          tynril Samuel Loretan added a comment -

          David Rodriguez – not Paul, but P4BaseCredentials is an abstract base class, you probably want one of its concrete implementation instead (P4PasswordImpl or P4TicketImpl).

          Show
          tynril Samuel Loretan added a comment - David Rodriguez – not Paul, but P4BaseCredentials is an abstract base class, you probably want one of its concrete implementation instead ( P4PasswordImpl or P4TicketImpl ).
          Hide
          drodspike David Rodriguez added a comment -

          Configured the JCasC jenkins.yaml file as follows with the "P4PasswordImpl" credentials  and was successful 

          credentials:
            system:
              domainCredentials:
              - credentials:
                - basicSSHUserPrivateKey:
                    description: "Private key credentials for Jenkins GitLab user"
                    id: "gitlab-key"
                    privateKeySource:
                      directEntry:
                        privateKey: "${GITLAB_PRIVATE_KEY}"
                    scope: GLOBAL
                    username: "${JENKINS_GITLAB_USER_NAME}"
                - P4PasswordImpl: 
                    description: "Perforce password credential"
                    id: "p4-userpass"
                    p4port: "${P4PORT}"
                    scope: GLOBAL
                    username: "${P4USER}"
                    password: "${P4PASSWD}"

          When attempting to view the configuration as code configuration, got an export error by doing:

              Manage jenkins --> Configuration as Code --> Actions: View Configuration

          credentials:
            system:
              domainCredentials:
              - credentials: |-
                  FAILED TO EXPORT
                  com.cloudbees.plugins.credentials.domains.DomainCredentials#credentials: java.lang.IllegalArgumentException: argument type mismatch
                    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

          Even though I got the EXPORT error, when trying to view the configuration,  the"P4 credential" in the jenkins.yaml  worked fine in a jenkins job.

           

          Show
          drodspike David Rodriguez added a comment - Configured the JCasC jenkins.yaml file as follows with the "P4PasswordImpl" credentials  and was successful  credentials: system: domainCredentials: - credentials: - basicSSHUserPrivateKey: description: "Private key credentials for Jenkins GitLab user" id: "gitlab-key" privateKeySource: directEntry: privateKey: "${GITLAB_PRIVATE_KEY}" scope: GLOBAL username: "${JENKINS_GITLAB_USER_NAME}" - P4PasswordImpl: description: "Perforce password credential" id: "p4-userpass" p4port: "${P4PORT}" scope: GLOBAL username: "${P4USER}" password: "${P4PASSWD}" When attempting to view the configuration as code configuration, got an export error by doing:     Manage jenkins --> Configuration as Code --> Actions: View Configuration credentials: system: domainCredentials: - credentials: |- FAILED TO EXPORT com.cloudbees.plugins.credentials.domains.DomainCredentials#credentials: java.lang.IllegalArgumentException: argument type mismatch at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) Even though I got the EXPORT error, when trying to view the configuration,  the"P4 credential" in the jenkins.yaml  worked fine in a jenkins job.  

            People

            • Assignee:
              p4paul Paul Allen
              Reporter:
              courteouselk Anton Bronnikov
            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated: