[英]How to enter git credentials in jenkins pipeline code
Am having a Jenkins server running on GCP-Linux Vm, I want to access a code from git's private repo, am trying to access it from my Jenkins pipeline code, how can I enter my git credentials in Jenkin pipeline code?我有一个在 GCP-Linux Vm 上运行的 Jenkins 服务器,我想从 git 的私有仓库访问代码,我试图从我的 Jenkins 管道代码中访问它,如何在 Jen 管道代码中输入我的 ZBA9F11ECC3497D9993B933FDC2BD 凭据?6
you should share the pipeline you use for more specific answers.您应该分享您用于更具体答案的管道。
As a general answer:作为一般答案:
In this case no special reference in pipeline code is necessary在这种情况下,不需要管道代码中的特殊引用
If you want to clone a second repository in your build you can use inside your pipeline:如果要在构建中克隆第二个存储库,可以在管道中使用:
pipeline {管道{
environment { gitCredentialId = 'Jenkins-Bitbucket' //defined in credentials area gitUrl = 'https://bitbucket.org/companyNameHere/repoNameHere.git' deployBranch = 'branch-name-here' } stages { stage('Cloning Git') { steps { git( url: gitUrl, credentialsId: gitCredentialId, branch: deployBranch ) } }
} }
to store credentials: manage jenkins > manage credentials > click on global domain > add credential.存储凭据:管理 jenkins > 管理凭据 > 单击全局域 > 添加凭据。 Make sure to put meaningful description and ids as this area tends to become a mess in time and it is hard to cleanup as you will never know what can be deleted.
确保放置有意义的描述和 ID,因为该区域往往会及时变得一团糟,并且很难清理,因为您永远不知道可以删除什么。
Each credential will tell you where it is used:每个凭证都会告诉您它的用途:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.