我正在使用git插件 https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin,据称它与“Jenkins 凭证管理功能”集成:
凭证:使用 Jenkins 凭证管理功能连接到存储库的凭证(除非允许匿名访问)。使用的凭据类型取决于底层协议。对于 SSH 连接,仅支持私钥身份验证。
太棒了,“Jenkins 凭证管理功能”对我来说很有效:我能够运行“SCM 的管道脚本”。
那么,如何通过 git 插件使用这些凭据? git 插件文档和网络中都没有示例。这是我的 Jenkinsfile 的相关部分,其中包含 git 步骤:
node {
stage('Checkout') {
git url: 'ssh://[email protected] /cdn-cgi/l/email-protection:5999/my/repo.git', branch: 'wip'
}
...
}
他们似乎同时添加了一些文档:https://jenkins.io/doc/pipeline/steps/git/ https://jenkins.io/doc/pipeline/steps/git/
因此,对于您的示例,以下内容应该有效:
checkout([$class: 'GitSCM', branches: [[name: '*/wip']],
userRemoteConfigs: [[url: 'ssh://[email protected] /cdn-cgi/l/email-protection:5999/my/repo.git',
credentialsId: 'your-credentials-id']]])
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)