Skip to content

[JENKINS-68162] NullPointerException from withCredentials > sshUserPrivateKey #320

@jenkins-infra-bot

Description

@jenkins-infra-bot

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.

 

 

 


Originally reported by dguha, imported from: NullPointerException from withCredentials > sshUserPrivateKey
  • assignee: jvz
  • status: Open
  • priority: Minor
  • component(s): ssh-credentials-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 2
  • imported: 20251215-193512
Raw content of original issue

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.

 

 

 

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions