jenkinsci / jenkinsci/ssh-credentials-plugin

[JENKINS-68162] NullPointerException from withCredentials > sshUserPrivateKey

Open
#320 1 comment 0 reactions 0 assignees View on GitHub
component:ssh-credentials-plugin imported-jira-issue priority:minor resolution:unresolved
Dominant language
Java
Stars
25
Forks
69
PR merge metrics
No merged PRs in 30d

Description

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.

 

 

 

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.