如何在Jenkins Workflow Plugin中使用SSH密钥

时间:2015-02-20 15:30:26

标签: git groovy jenkins ssh-keys jenkins-workflow

有一个由Jenkins Worflow Plugin执行的groovy脚本。

作为documented,git步骤到目前为止只有基本配置,只有一个url参数,并且suggested使用常规checkout scm步骤来处理更复杂的事情。

有了这个,就可以传递credentialsId:

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

但是如何才能使用SSH密钥凭证来实现呢?

1 个答案:

答案 0 :(得分:2)

相同的语法应该适用于SSH私钥凭证。

1.4开始,您可以将credentialsId传递给简单的git步骤。

此外,如果您更新SSH凭据插件,您还可以选择人类可读的ID(在创建新凭证项时)。