Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-42582

ssh-agent not applied in kubernetes container

XMLWordPrintable

      the ssh-agent configuration isn't applied when pipeline is run on a docker container using the kubernetes plugin

       

      as an example, this pipeline works fine:

      sshagent in basic pipeline
      node {
          stage('Pre-Build') {
              sshagent (credentials: ['jenkins-master-ssh']) {
                  sh 'ssh -vT -o "StrictHostKeyChecking=no" git@github.com'
              }
          }
      }
      

      the job will fail, but the console output will clearly show the error from github 

      You've successfully authenticated, but GitHub does not provide shell access.

       

      whereas

      sshagent not applied in container 
      podTemplate(label: 'jenkpod', containers: [containerTemplate(name: 'golang', image: 'golang:1.8', ttyEnabled: true, command: 'cat')]) {
          node ('jenkpod') { container('golang') {
      
              stage('Pre-Build') {
                  sshagent (credentials: ['jenkins-master-ssh']) {
                      sh 'ssh -vT -o "StrictHostKeyChecking=no" git@github.com'
                  }
              }
      
          } }
      }
      

      fails with public key error:

      debug1: Authentications that can continue: publickey
      debug1: Next authentication method: publickey
      debug1: Trying private key: /root/.ssh/id_rsa
      debug1: Trying private key: /root/.ssh/id_dsa
      debug1: Trying private key: /root/.ssh/id_ecdsa
      debug1: Trying private key: /root/.ssh/id_ed25519
      debug1: No more authentication methods to try.
      Permission denied (publickey).

       

      this seems closely related to -JENKINS-32624 sshagent{} ignored when executed in docker.image().inside

       

            seakip18 Matthew Ludlum
            jknurek J Knurek
            Votes:
            6 Vote for this issue
            Watchers:
            23 Start watching this issue

              Created:
              Updated:
              Resolved: