[JIRA] (JENKINS-43050) SSH Agent plugin doesn't work well with docker pipelines

2 views
Skip to first unread message

erik.latt@gmail.com (JIRA)

unread,
Mar 22, 2017, 6:06:01 PM3/22/17
to jenkinsc...@googlegroups.com
Erik Lattimore created an issue
 
Jenkins / Bug JENKINS-43050
SSH Agent plugin doesn't work well with docker pipelines
Issue Type: Bug Bug
Assignee: Unassigned
Components: ssh-agent-plugin
Created: 2017/Mar/22 10:05 PM
Priority: Minor Minor
Reporter: Erik Lattimore

I've tried

dockerImage.inside {
  sshagent([...]) {
    sh '...'
  }
}

and this appears to fail because the ssh-agent gets launched but then the next command
appears to be ssh-agent -k which kills the process before the sh step has a chance to run despite the sh command being inside the sshagent block.

And also

sshagent([...]){
  dockerImage.inside {
    sh '...'
  }
}

fails (I think) for a more predictable reason: the ssh-agent stays running and the env variables get
set correctly inside the container, however the socket is in /tmp on the container server which is not visible to the container (by default).

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

kostya.ripak@gmail.com (JIRA)

unread,
Feb 22, 2018, 3:59:02 AM2/22/18
to jenkinsc...@googlegroups.com
Konstantin Ripak commented on Bug JENKINS-43050
 
Re: SSH Agent plugin doesn't work well with docker pipelines

Well, I think I found how to reproduce the issue.

The following code works as expected if running on non-docker agent and does not work inside docker:

 

agent {
    docker {
        label 'bsp'
        image 'my-registry/my-image'
        reuseNode true
    }
}
stage("Some stage") {
    steps {
        sshagent(['some-id']) {
            script {
               sh "# some code that uses ssh"
            }
        }
    }
}

 

However, if I put sshagent() inside script {...} block it works:

agent {
    docker {
        label 'bsp'
        image 'my-registry/my-image'
        reuseNode true
    }
}
stage("Some stage") {
    steps {
        script {
            sshagent(['some-id']) {
               sh "# some code that uses ssh"
            }
        }
    }
}

 

krishnababu505@gmail.com (JIRA)

unread,
Dec 12, 2019, 5:26:03 AM12/12/19
to jenkinsc...@googlegroups.com
krishnababu reddy updated an issue
 
Change By: krishnababu reddy
Priority: Minor Critical
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages