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

NullPointerException from withCredentials > sshUserPrivateKey

XMLWordPrintable

      Hello!

      Here is a snippet from Pipeline:

       

      sshagent(["AWSServerPrivateKey-${params.URL}"]) {
       withCredentials([sshUserPrivateKey(credentialsId: "AWSServerPrivateKey-${params.URL}", usernameVariable: 'userName')]) {
        sh "cat hello.txt"
        }
       }

      I get the following error

       

      [Pipeline] }
      [Pipeline] // script
      [Pipeline] }
      
      [Pipeline] // ansiColor
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] stage
      [Pipeline] { (deploy)
      [Pipeline] sshagent
      [ssh-agent] Using credentials *** (AWSServerPrivateKey)
      [ssh-agent] Looking for ssh-agent implementation...
      [ssh-agent]   Exec ssh-agent (binary ssh-agent on a remote machine)
      $ ssh-agent
      SSH_AUTH_SOCK=/tmp/ssh-2FrmRJy4jjPF/agent.2510759
      SSH_AGENT_PID=2510761
      Running ssh-add (command line suppressed)
      Identity added: 
      ...
      [ssh-agent] Started.
      [Pipeline] {
      [Pipeline] withCredentials
      Masking supported pattern matches of $null
      [Pipeline] {
      [Pipeline] }
      [Pipeline] // withCredentials
      [Pipeline] }
      $ ssh-agent -k
      unset SSH_AUTH_SOCK;
      unset SSH_AGENT_PID;
      echo Agent pid 2510761 killed;
      [ssh-agent] Stopped.
      [Pipeline] // sshagent
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] stage
      [Pipeline] { (Declarative: Post Actions)
      [Pipeline] sh
      ...
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // withEnv
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      java.lang.NullPointerException
      Finished: FAILURE
      

      Please advise.

       

       

       

            jvz Matt Sicker
            dguha Debasish Guha
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: