Hi,
I have pipeline job that uses ssh agent step to set up credentials to
connect to git repository and clone it. When i execute the job on the
master jenkins, it runs flawlesly. When run it on a slave it fails because
ssh agent closes before the git clone.
This is an example of the code that produces the error:
node
{
def credentials = 'somecredentials'
sshagent (credentials: [credentials])
{
sh ( script:"""
rm -rf common_jenkins_jobs
git clone ssh://[email protected]
""")
}
}
node ( "ci-server-slave" )
{
def credentials = 'somecredentials'
sshagent (credentials: [credentials])
{
sh ( script:"""
rm -rf common_jenkins_jobs
git clone ssh://[email protected]
""")
}
}
The first block runs on the master node and the seccond on the slave.
Examing the execution logs of the first block you can see the sequence:
1. ssh-agent start
2. rm
3. git
4. ssh-agent stop
but the part that runs on the slave shows the sequence:
1. ssh-agent start
2. ssh-agent stop
3. rm
4. git
leaving the git clone out of the ssh-agent environment and failing due to
lack of crecedentials.
I attached the log of the second node on a simpler test where the sh step
only runs an ls ltr command. There you can clearly see that the ls command
runs after the ssh-agent ends.
¿ Can this behaviour be part of some missconfiguration on my part or is a
bug on the ssh agent step ?
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/f2f2747e-a13b-450a-b7b8-f10474478113%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
[Pipeline] node
Running on ci-server-slave in /var/jenkins_home/workspace/simple test
[Pipeline] {
[Pipeline] sshagent
[ssh-agent] Using credentials fbomana (credenciales para conectarse a forge.)
[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-lcweSTQQVrOu/agent.3334
SSH_AGENT_PID=3335
$ ssh-add "/var/jenkins_home/workspace/simple
test@tmp/private_key_6375647463696235768.key"
Identity added: /var/jenkins_home/workspace/simple
test@tmp/private_key_6375647463696235768.key
(/var/jenkins_home/workspace/simple
test@tmp/private_key_6375647463696235768.key)
[ssh-agent] Started.
[Pipeline] {
[Pipeline] sh
[simple test] Running shell script
$ ssh-agent -k
unset SSH_AUTH_SOCK;
unset SSH_AGENT_PID;
echo Agent pid 3335 killed;
[ssh-agent] Stopped.
+ ls -ltr
total 0
[Pipeline] }
[Pipeline] // sshagent
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline