I am new to Jenkinsfile. I have previously configured my Jenkins job from GUI, and we are now upgrading our server to use Jenkinsfile. My job contains a section which needs to SSH to another server. To do this, I previously used the sshagent plugin on the GUI to specify my keys. However, on the jenkinsfile mechanism this does not work.

First things first: Aside from using jenkinsfile, we have also trasitioned to building in docker. I read in some places that docker might conflict with sshagent plugin, so I am trying to remove docker by starting a clean job with "agent any" and trying to test.

So my new job looks like this:

    @NonCPS  // Necessary to allow .each to work.
def changelist() {
    def changes = ""
    currentBuild.changeSets.each { set ->
        set.each { entry ->
            changes += "${entry.author.id} "

pipeline {
    agent none
    stages {
            stage('test') {
            agent any
            steps {
                sshagent ( ['a-jenkins-credential']) {
    sh '''
ssh -vv myuser@myserver echo testing connection || true
ssh-add -L
echo done running remote windows test


On the same server, but using the jenkins GUI, this works flawlessly, but on the jenkinsfile pipeline this produces:

FATAL: [ssh-agent] Could not find specified credentials

and proceeds run and fail on the ssh command. The funny thing is, that this job uses the exact same key to succesfully pull from GIT, so it's not like it's not installed on the server.

1 Answer 1


Found the problem:

I was using the human readable key name from the GUI. Need to use the key's UUId ID instead (this is specified next to the name in credentials screen)

steps {
  • Would you be so kind as to show an example of the UUID in the GUI?
    – 2rs2ts
    Commented Nov 13, 2018 at 20:09
  • Project is no longer active, so I don't have a screenshot. However, when you dig around your credentials in your Jenkins configuration: You will find configuration screen where your key has 2 attributes: It has a human readable name such as: "My_Dev_Credentials" which is displayed in most screens. But, it also has a unique id which should look something like a long hexadecimal string (which is garbage to humans). It should look something like: "571fe649-7844-4e93-891e-35496cc8cc72 " . Basically you should referemce that hex ID instead of the English name of your credentials. I hope that helps
    – eshalev
    Commented Nov 14, 2018 at 22:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.