3

Have a groovy script that's executed by the Jenkins Worflow Plugin.

As documented, the git step has only basic configuration so far, having only a single url parameter, and it's suggested to use the general checkout scm step for anything more complex.

With this, it's possible to pass credentialsId as so:

checkout scm: [$class: 'MercurialSCM', source: 'ssh://hg@bitbucket.org/user/repo', clean: true, credentialsId: '1234-5678-abcd']

But how would one get this to work with an SSH key credentials instead?

Jesse Glick
  • 24,539
  • 10
  • 90
  • 112
Andrew Eells
  • 735
  • 12
  • 30

1 Answers1

2

The same syntax should work for SSH private key credentials.

By the way as of 1.4 you can pass credentialsId to the simple git step.

Also if you update the SSH Credentials plugin you can also choose a human-readable ID (when creating a new credentials item).

Jesse Glick
  • 24,539
  • 10
  • 90
  • 112
  • 1
    Absolutely, I myself am glad I found this. Make note that the JIRA issue displays the `credentialsId` being passed without quotes. You need to make sure to pass quotes (single, I suppose) to ensure that it works, like so `git url: 'ssh://git@repourl/project.git', credentialsId: 'someIDHere'`, otherwise your build with fail with a stacktrace. – signus Sep 01 '15 at 19:08