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

NPE generating snippet for BindingStep

    XMLWordPrintable

Details

    Description

      Not clear how to reproduce.

      java.lang.RuntimeException: Failed to instantiate class org.jenkinsci.plugins.credentialsbinding.impl.BindingStep from {"stapler-class":"org.jenkinsci.plugins.credentialsbinding.impl.BindingStep","bindings":{"variable":"foo","credentialsId":["",""],"stapler-class":"org.jenkinsci.plugins.credentialsbinding.impl.StringBinding","kind":"org.jenkinsci.plugins.credentialsbinding.impl.StringBinding"}}
      	at hudson.model.Descriptor.newInstance(Descriptor.java:577)
      	at org.jenkinsci.plugins.workflow.cps.Snippetizer.doGenerateSnippet(Snippetizer.java:203)
      	at ...
      Caused by: java.lang.NullPointerException
      	at org.kohsuke.stapler.RequestImpl$TypePair.convertJSON(RequestImpl.java:632)
      	at org.kohsuke.stapler.RequestImpl.bindJSON(RequestImpl.java:400)
      	at org.kohsuke.stapler.RequestImpl.instantiate(RequestImpl.java:684)
      	at org.kohsuke.stapler.RequestImpl.access$100(RequestImpl.java:81)
      	at org.kohsuke.stapler.RequestImpl$TypePair.convertJSON(RequestImpl.java:587)
      	at org.kohsuke.stapler.RequestImpl$TypePair.convertJSON(RequestImpl.java:625)
      	at org.kohsuke.stapler.RequestImpl.bindJSON(RequestImpl.java:400)
      	at org.kohsuke.stapler.RequestImpl.instantiate(RequestImpl.java:684)
      	at org.kohsuke.stapler.RequestImpl.access$100(RequestImpl.java:81)
      	at org.kohsuke.stapler.RequestImpl$TypePair.convertJSON(RequestImpl.java:587)
      	at org.kohsuke.stapler.RequestImpl.bindJSON(RequestImpl.java:400)
      	at org.kohsuke.stapler.RequestImpl.bindJSON(RequestImpl.java:396)
      	at hudson.model.Descriptor.newInstance(Descriptor.java:568)
      	... 56 more
      

      Attachments

        Issue Links

          Activity

            jglick Jesse Glick created issue -
            jglick Jesse Glick made changes -
            Field Original Value New Value
            Link This issue is duplicated by JENKINS-27960 [ JENKINS-27960 ]
            jglick Jesse Glick made changes -
            Link This issue is related to JENKINS-27397 [ JENKINS-27397 ]
            jglick Jesse Glick made changes -
            Link This issue is duplicated by JENKINS-28988 [ JENKINS-28988 ]
            jglick Jesse Glick made changes -
            Link This issue is duplicated by JENKINS-31813 [ JENKINS-31813 ]

            Hi,

            I'm getting the same error than you, see below. Any update in this fix?

            java.lang.RuntimeException: Failed to instantiate class org.jenkinsci.plugins.credentialsbinding.impl.BindingStep from {"bindings":

            {"usernameVariable":"svn_username","passwordVariable":"svn_password","credentialsId":["59a9e8cb-97e8-4fca-9c4a-06764843d039",""],"stapler-class":"org.jenkinsci.plugins.credentialsbinding.impl.UsernamePasswordMultiBinding","$class":"org.jenkinsci.plugins.credentialsbinding.impl.UsernamePasswordMultiBinding"}

            ,"stapler-class":"org.jenkinsci.plugins.credentialsbinding.impl.BindingStep","$class":"org.jenkinsci.plugins.credentialsbinding.impl.BindingStep"}

            susie susie hernandez added a comment - Hi, I'm getting the same error than you, see below. Any update in this fix? java.lang.RuntimeException: Failed to instantiate class org.jenkinsci.plugins.credentialsbinding.impl.BindingStep from {"bindings": {"usernameVariable":"svn_username","passwordVariable":"svn_password","credentialsId":["59a9e8cb-97e8-4fca-9c4a-06764843d039",""],"stapler-class":"org.jenkinsci.plugins.credentialsbinding.impl.UsernamePasswordMultiBinding","$class":"org.jenkinsci.plugins.credentialsbinding.impl.UsernamePasswordMultiBinding"} ,"stapler-class":"org.jenkinsci.plugins.credentialsbinding.impl.BindingStep","$class":"org.jenkinsci.plugins.credentialsbinding.impl.BindingStep"}
            cleclerc Cyrille Le Clerc made changes -
            Attachment screenshot-1.png [ 31700 ]

            I found a workaround when I was getting an NPE generating the snippet of a "Secret File" binding.
            I first add a binding that does not break, a "Username and password (conjoined)" binding and then the "Secret File" binding that I need. And then I can generate the groovy snippet. I just have to remove the generated binding for the "Username and password (conjoined)" and I'm done.

            cleclerc Cyrille Le Clerc added a comment - I found a workaround when I was getting an NPE generating the snippet of a "Secret File" binding. I first add a binding that does not break, a "Username and password (conjoined)" binding and then the "Secret File" binding that I need. And then I can generate the groovy snippet. I just have to remove the generated binding for the "Username and password (conjoined)" and I'm done.
            jglick Jesse Glick made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            jglick Jesse Glick added a comment -

            The problem is that credentialsId is being passed as an array rather than a single value, and this code is incompatible with databinding stephenconnolly. Somehow it works in SecretBuildWrapper in a freestyle project, not sure how.

            jglick Jesse Glick added a comment - The problem is that credentialsId is being passed as an array rather than a single value, and this code is incompatible with databinding stephenconnolly . Somehow it works in SecretBuildWrapper in a freestyle project, not sure how.
            jglick Jesse Glick made changes -
            Remote Link This issue links to "PR 15 (Web Link)" [ 14017 ]

            Code changed in jenkins
            User: Jesse Glick
            Path:
            src/main/resources/org/jenkinsci/plugins/credentialsbinding/MultiBinding/config.jelly
            src/main/resources/org/jenkinsci/plugins/credentialsbinding/impl/BindingStep/config.jelly
            src/main/resources/org/jenkinsci/plugins/credentialsbinding/impl/SecretBuildWrapper/config.jelly
            http://jenkins-ci.org/commit/credentials-binding-plugin/1aa7d7ad6cbb6cf5ac6a4d246704de0f42af8456
            Log:
            [FIXED JENKINS-27387] Suppress expressionAllowed in BindingStep config; unnecessary and throws exceptions.

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/main/resources/org/jenkinsci/plugins/credentialsbinding/MultiBinding/config.jelly src/main/resources/org/jenkinsci/plugins/credentialsbinding/impl/BindingStep/config.jelly src/main/resources/org/jenkinsci/plugins/credentialsbinding/impl/SecretBuildWrapper/config.jelly http://jenkins-ci.org/commit/credentials-binding-plugin/1aa7d7ad6cbb6cf5ac6a4d246704de0f42af8456 Log: [FIXED JENKINS-27387] Suppress expressionAllowed in BindingStep config; unnecessary and throws exceptions.
            scm_issue_link SCM/JIRA link daemon made changes -
            Resolution Fixed [ 1 ]
            Status In Progress [ 3 ] Resolved [ 5 ]

            Code changed in jenkins
            User: Jesse Glick
            Path:
            src/main/resources/org/jenkinsci/plugins/credentialsbinding/MultiBinding/config.jelly
            src/main/resources/org/jenkinsci/plugins/credentialsbinding/impl/BindingStep/config.jelly
            src/main/resources/org/jenkinsci/plugins/credentialsbinding/impl/SecretBuildWrapper/config.jelly
            http://jenkins-ci.org/commit/credentials-binding-plugin/fbefd8d4646fa28d971a102c368f5bcfad5a7ac6
            Log:
            Merge pull request #15 from jglick/snippetizer-JENKINS-27387

            JENKINS-27387 NPE from Snippetizer

            Compare: https://github.com/jenkinsci/credentials-binding-plugin/compare/ed93648cf840...fbefd8d4646f

            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/main/resources/org/jenkinsci/plugins/credentialsbinding/MultiBinding/config.jelly src/main/resources/org/jenkinsci/plugins/credentialsbinding/impl/BindingStep/config.jelly src/main/resources/org/jenkinsci/plugins/credentialsbinding/impl/SecretBuildWrapper/config.jelly http://jenkins-ci.org/commit/credentials-binding-plugin/fbefd8d4646fa28d971a102c368f5bcfad5a7ac6 Log: Merge pull request #15 from jglick/snippetizer- JENKINS-27387 JENKINS-27387 NPE from Snippetizer Compare: https://github.com/jenkinsci/credentials-binding-plugin/compare/ed93648cf840...fbefd8d4646f

            The fix for this has broken the use case of binding a credentials parameter in a freestyle job

            stephenconnolly Stephen Connolly added a comment - The fix for this has broken the use case of binding a credentials parameter in a freestyle job
            jglick Jesse Glick made changes -
            Link This issue is related to JENKINS-35490 [ JENKINS-35490 ]
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 161592 ] JNJira + In-Review [ 196807 ]
            rarabaolaza Raul Arabaolaza made changes -
            Link This issue is related to JENKINS-37707 [ JENKINS-37707 ]
            abayer Andrew Bayer made changes -
            Labels stapler workflow pipeline stapler workflow
            abayer Andrew Bayer made changes -
            Labels pipeline stapler workflow pipeline stapler

            People

              jglick Jesse Glick
              jglick Jesse Glick
              Votes:
              3 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: