Re-use already running ssh-agent if any

prepareSshAgentKey() will not start ssh-agent if there is already
running any ssh-agent process, as the result there will be no
"config" file (~/.ssh/ssh-agent.sh) and runSshAgentCommand fails

Instead we need to re-use already running ssh-agent and re-construct
  * SSH_AUTH_SOCK
  * SSH_AGENT_PID

E.g:
  [env-01-configure-system] Running shell script
   + head -n 1
   + grep /tmp/ssh-.*/agent.*
   + find /tmp/ -type s -name agent.*
   + export SSH_AUTH_SOCK=/tmp/ssh-NQmNvs9SM9wu/agent.5363
   + echo /tmp/ssh-NQmNvs9SM9wu/agent.5363
   + cut -d. -f2
   + export SSH_AGENT_PID=5363
   + ssh-add /home/jenkins/.ssh/id_rsa_deployments-key
   Identity added: /home/jenkins/.ssh/id_rsa_deployments-key (/home/jenkins/.ssh/id_rsa_deployments-key)

Change-Id: I1e7126513fa623c83b5fdd3448a4654e24f09e33
1 file changed
tree: e2c480d74784be1168901725217d4c09e2cfb6a7
  1. src/
  2. vars/
  3. .gitignore
  4. .gitreview
  5. build.gradle
  6. codenarcRules.groovy