处理SSH密钥以克隆私有存储库的正确方法

时间:2018-10-12 09:54:29

标签: git jenkins

由于当前我们的构建需要克隆私有存储库中的依赖关系,我如何才能正确地使用Declarative / Scripted管道克隆私有存储库?

{{1}}

1 个答案:

答案 0 :(得分:0)

希望这就是您想要的。在Jenkins服务器上创建以“ jenkins”用户身份登录的私钥/公钥对。使用公共密钥设置Git用户的个人资料(有权访问私有存储库)。将私钥添加到Jenkins服务器上的ssh-agent。

在管道脚本中使用SCM签出以使用SSH URL克隆存储库

https://jenkins.io/doc/pipeline/steps/workflow-scm-step/

Bitbucket回购示例:

checkout poll: false, scm: [$class: 'GitSCM', branches: [[name: 
"refs/heads/${branchName}"]], doGenerateSubmoduleConfigurations: false, extensions: 
[], submoduleCfg: [], userRemoteConfigs: [[url:"git@bitbucket.org:${repoName}.git"]]]
相关问题