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

sshagent{} ignored when executed in docker.image().inside{...}

    Details

    • Similar Issues:

      Description

      sshagent('my-ssh-key'){...} is ignored in docker.image('cloudbees:java-build-tools').inside{...}. The same sshagent step works in 'standard' linux node.

      See attached logs

      sshagent(){...} ignored in docker.image(...).inside{...} 
      docker.image ('cloudbees/java-build-tools:0.0.7.1').inside {
          sh 'ls -al ~/.ssh/ || true'
          sshagent(['aws-cleclerc-ssh-key-ubuntu-cleclerc']) {
             sh 'echo SSH_AUTH_SOCK=$SSH_AUTH_SOCK'
             sh 'ls -al $SSH_AUTH_SOCK || true'
             sh "ssh -vvv -o StrictHostKeyChecking=no ubuntu@docker-agent.beesshop.org uname -a"
          }
      }
      
      sshagent(){...} WORKS in node{...} 
      node {
          sh 'ls -al ~/.ssh/ || true'
          sshagent(['aws-cleclerc-ssh-key-ubuntu-cleclerc']) {
             sh 'echo SSH_AUTH_SOCK=$SSH_AUTH_SOCK'
             sh 'ls -al $SSH_AUTH_SOCK || true'
             sh "ssh -vvv -o StrictHostKeyChecking=no ubuntu@docker-agent.beesshop.org uname -a"
          }
      }
      

        Attachments

          Issue Links

            Activity

            cleclerc Cyrille Le Clerc created issue -
            cleclerc Cyrille Le Clerc made changes -
            Field Original Value New Value
            Environment CloudBees Docker Workflow 1.2
            Jenkins ver. 1.625.3.1 (CloudBees Jenkins Enterprise 15.11)
            cleclerc Cyrille Le Clerc made changes -
            Description {{sshagent(...)\{...\}}} is ignored in {{docker.image(...).inside\{...\}}}. The same sshagent step works in 'standard' linux node.

            See attached logs

            {code:title=sshagent()\{...\} ignored in docker.image(...).inside\{...\} }
            docker.image ('cloudbees/java-build-tools:0.0.7.1').inside {
                sh 'ls -al ~/.ssh/ || true'
                sshagent(['aws-cleclerc-ssh-key-ubuntu-cleclerc']) {
                   sh 'echo SSH_AUTH_SOCK=$SSH_AUTH_SOCK'
                   sh 'ls -al $SSH_AUTH_SOCK || true'
                   sh "ssh -vvv -o StrictHostKeyChecking=no ubuntu@docker-agent.beesshop.org uname -a"
                }
            }
            {code}

            {code:title=sshagent()\{...\} WORKS in node\{...\} }
            node {
                sh 'ls -al ~/.ssh/ || true'
                sshagent(['aws-cleclerc-ssh-key-ubuntu-cleclerc']) {
                   sh 'echo SSH_AUTH_SOCK=$SSH_AUTH_SOCK'
                   sh 'ls -al $SSH_AUTH_SOCK || true'
                   sh "ssh -vvv -o StrictHostKeyChecking=no ubuntu@docker-agent.beesshop.org uname -a"
                }
            }
            {code}
            {{sshagent('my-ssh-key')\{...\}}} is ignored in {{docker.image('cloudbees:java-build-tools').inside\{...\}}}. The same sshagent step works in 'standard' linux node.

            See attached logs

            {code:title=sshagent()\{...\} ignored in docker.image(...).inside\{...\} }
            docker.image ('cloudbees/java-build-tools:0.0.7.1').inside {
                sh 'ls -al ~/.ssh/ || true'
                sshagent(['aws-cleclerc-ssh-key-ubuntu-cleclerc']) {
                   sh 'echo SSH_AUTH_SOCK=$SSH_AUTH_SOCK'
                   sh 'ls -al $SSH_AUTH_SOCK || true'
                   sh "ssh -vvv -o StrictHostKeyChecking=no ubuntu@docker-agent.beesshop.org uname -a"
                }
            }
            {code}

            {code:title=sshagent()\{...\} WORKS in node\{...\} }
            node {
                sh 'ls -al ~/.ssh/ || true'
                sshagent(['aws-cleclerc-ssh-key-ubuntu-cleclerc']) {
                   sh 'echo SSH_AUTH_SOCK=$SSH_AUTH_SOCK'
                   sh 'ls -al $SSH_AUTH_SOCK || true'
                   sh "ssh -vvv -o StrictHostKeyChecking=no ubuntu@docker-agent.beesshop.org uname -a"
                }
            }
            {code}
            cleclerc Cyrille Le Clerc made changes -
            Link This issue depends on JENKINS-27152 [ JENKINS-27152 ]
            cleclerc Cyrille Le Clerc made changes -
            Component/s ssh-agent-plugin [ 17509 ]
            jglick Jesse Glick made changes -
            Link This issue duplicates JENKINS-27152 [ JENKINS-27152 ]
            jglick Jesse Glick made changes -
            Status Open [ 1 ] Resolved [ 5 ]
            Resolution Duplicate [ 3 ]
            jglick Jesse Glick made changes -
            Link This issue depends on JENKINS-27152 [ JENKINS-27152 ]
            rtyler R. Tyler Croy made changes -
            Link This issue is related to JENKINS-27152 [ JENKINS-27152 ]
            rtyler R. Tyler Croy made changes -
            Link This issue is related to JENKINS-27152 [ JENKINS-27152 ]
            sdomula Stan Domula made changes -
            Comment [ I'm having the exact same issue if the script is executed via Jenkinsfile with the GitHub Organisation Plugin. Same script copied into a Pipeline Job works. It works while using Jenkinsfile and using node{} instead of docker.image.inside.

            Jenkins: 2.7.1 LTS
            SSH Agent Plugin: 1.13 ]
            sdomula Stan Domula made changes -
            Comment [ The same error occures if the job's workspace tmp path + socket name gets longer than 108. It works with node, but not with docker.image.inside {}

            It seems like it is not creating the link under '/tmp/../' if the sockets path gets longer than UNIX_PATH_MAX.

            {code}
            [Pipeline] {
            [Pipeline] sshagent
            [ssh-agent] Using credentials ubuntu (develop ssh key)
            [ssh-agent] Looking for ssh-agent implementation...
            [ssh-agent] Java/JNR ssh-agent
            [ssh-agent] Skipped registering BouncyCastle, not running on a remote agent
            [ssh-agent] Started.
            [Pipeline] {
            [Pipeline] sh
            [asdfasdlkfajsdlkjfklasdjlfjaklsdjfjaklsdjflkjasdkljfljasdljflkajsdjfasjdlfjaskldjfljasdlkjfl] Running shell script
            + echo SSH_AUTH_SOCK=/tmp/ssh6669368941114379204
            SSH_AUTH_SOCK=/tmp/ssh6669368941114379204
            [Pipeline] sh
            [asdfasdlkfajsdlkjfklasdjlfjaklsdjfjaklsdjflkjasdkljfljasdljflkajsdjfasjdlfjaskldjfljasdlkjfl] Running shell script
            + ls -al /tmp/ssh6669368941114379204
            ls: /tmp/ssh6669368941114379204: No such file or directory
            {code} ]
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 168281 ] JNJira + In-Review [ 198387 ]
            jknurek J Knurek made changes -
            Link This issue is related to JENKINS-42582 [ JENKINS-42582 ]

              People

              • Assignee:
                jglick Jesse Glick
                Reporter:
                cleclerc Cyrille Le Clerc
              • Votes:
                1 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: