ssh-agent + checkout scm

63 views
Skip to first unread message

Sébastien Rainville

unread,
Nov 15, 2016, 7:49:02 PM11/15/16
to jenkins...@googlegroups.com
Hi,

I haven't been able to get ssh-agent and checkout scm to work together, e.g.:

node('slave') {
  sshagent (credentials: ['master-credentials']) {
    checkout scm
  }
}

For some reason the ssh-agent is stopped before the checkout is executed:

[Pipeline] node
Running on ... (truncated)
[Pipeline] {
[Pipeline] sshagent
[ssh-agent] Using credentials master-credentials
[ssh-agent] Looking for ssh-agent implementation...
[ssh-agent]   Java/JNR ssh-agent
[ssh-agent] Registered BouncyCastle on the remote agent
[ssh-agent] Started.
[Pipeline] {
[Pipeline] checkout
[ssh-agent] Stopped.
Cloning the remote Git repository
Cloning repository g...@github.mydomain:Organization/my-project.git
 > git init ... (truncated)
 > git --version # timeout=10
 > git fetch  ... (truncated)
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --progress g...@github.mydomain:Organization/my-project.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: Permission denied (publickey).
fatal: The remote end hung up unexpectedly


It doesn't work with the 'git' step either:

node('slave') {
  sshagent (credentials: ['master-credentials']) {
    git url: "g...@github.mydomain:Organization/my-project.git"
  }
}


But it does work with 'sh':

node('slave') {
  sshagent (credentials: ['master-credentials']) {
    sh 'git clone g...@github.mydomain:Organization/my-project.git'
  }
}


What's the difference between these? How come the ssh-agent is allowed to stop before the end of its closure with the first two versions and not with 'sh'?

Thanks,

- Sebastien



Reply all
Reply to author
Forward
0 new messages