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

nullpointerexception

XMLWordPrintable

      Jenkins 1.658 and SSH Credentials 1.10 and 1.11

      The command: /usr/lib/jvm/java-1.8.0/bin/java -jar /var/chef/cache/jenkins-cli.jar -s http://jenkins.our.org:8080 -i /var/chef/cache/jenkins-key groovy /tmp/groovy20160506-13473-xnbfhf

      Where /tmp/groovy20160506-13473-xnbfhf consists of:

              import com.cloudbees.plugins.credentials.impl.*;
              import com.cloudbees.jenkins.plugins.sshcredentials.impl.*;
              import jenkins.model.*
              import com.cloudbees.plugins.credentials.*
              import com.cloudbees.plugins.credentials.common.*
              import com.cloudbees.plugins.credentials.domains.*;
      
              username_matcher = CredentialsMatchers.withUsername("jenkins")
              available_credentials =
                CredentialsProvider.lookupCredentials(
                  StandardUsernameCredentials.class,
                  Jenkins.getInstance(),
                  hudson.security.ACL.SYSTEM,
                  new SchemeRequirement("ssh")
                )
      
              credentials =
                CredentialsMatchers.firstOrNull(
                  available_credentials,
                  username_matcher
                )
      
              if (credentials == null) {
                return null
              }
      
              current_credentials = [
                id:credentials.id,
                description:credentials.description,
                username:credentials.username
              ]
      
              current_credentials['private_key'] = credentials.privateKey
      current_credentials['passphrase'] = credentials.passphrase.plainText
      
              builder = new groovy.json.JsonBuilder(current_credentials)
              println(builder)
      

      Results in:

      java.lang.NullPointerException
      	at com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey.getPrivateKeys(BasicSSHUserPrivateKey.java:127)
      	at com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey.getPrivateKey(BasicSSHUserPrivateKey.java:121)
      	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:90)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
      	at groovy.lang.MetaClassImpl$GetBeanMethodMetaProperty.getProperty(MetaClassImpl.java:3500)
      	at org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:61)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:227)
      	at RemoteClass.run(RemoteClass:35)
      	at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:266)
      	at groovy.lang.GroovyShell.run(GroovyShell.java:517)
      	at hudson.cli.GroovyCommand.run(GroovyCommand.java:86)
      	at hudson.cli.CLICommand.main(CLICommand.java:256)
      	at hudson.cli.CliManagerImpl.main(CliManagerImpl.java:92)
      	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 hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:608)
      	at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:583)
      	at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:542)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:120)
      	at hudson.remoting.UserRequest.perform(UserRequest.java:48)
      	at hudson.remoting.Request$2.run(Request.java:332)
      	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
      	at hudson.cli.CliManagerImpl$1.call(CliManagerImpl.java:63)
      	at hudson.remoting.CallableDecoratorAdapter.call(CallableDecoratorAdapter.java:18)
      	at hudson.remoting.CallableDecoratorList$1.call(CallableDecoratorList.java:21)
      	at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      

            stephenconnolly Stephen Connolly
            jblaine Jeff Blaine
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: