2017-01-04 34 views
1

即时使用jenikins管道作为代码来克隆位于专用bitbucket存储库(存储库)中的git项目。我用这个代码块克隆我的管道脚本中的项目。使用jenkins从bitbucket私有存储库克隆管道作为代码

node { 
//checkout from master 
stage 'checkout' 
    withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'MyID', usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD']]) { 

     git url: 'https://[email protected]/stash/scm/test_automation.git' , branch: 'development' 
    } 
} 

“身份识别码”是的凭证ID和我的用户名和密码是correct.i救我在全球凭据凭据詹金斯功能。但是当我建立詹金斯任务时,我得到这个错误。

 
ERROR: Error fetching remote repo 'origin' 
hudson.plugins.git.GitException: Failed to fetch from https://[email protected]/stash/scm/test_automation.git 
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:803) 
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1063) 
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1094) 
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:109) 
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:83) 
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:73) 
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47) 
    at hudson.security.ACL.impersonate(ACL.java:221) 
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44) 
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress https://[email protected]/stash/scm/test_automation.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: 
stdout: 
stderr: fatal: Authentication failed for 'https://[email protected]/stash/scm/test_automation.git/' 

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1745) 
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1489) 
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:64) 
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:315) 
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:801) 

在我的Mac机下我paulrda帐户,我可以使用詹金斯管道脚本成功克隆我的项目,但是当我切换到另一个帐户,并运行詹金斯我得到这个错误。我仍然不明白为什么我得到这个错误。请提供解决此问题的方法。

我的配置。
詹金斯版本:2.19.2
证书插件:2.1.8
Git的插件:3.0.0
Git的客户端插件:2.1.0

+0

以下错误消息说'验证失败的“https:// @ ralles dev.zaizi.org',这比你的代码不同的用户名以上(按意图?)。但请检查用户名和密码。您还可以在'withCredentials'步骤中使用'sh“echo $ GIT_PASSWORD”'来验证。 – StephenKing

+0

因此,阅读整个错误消息可能不仅可以帮助您解决问题,还可以应用匿名化;-) – StephenKing

回答

4

它的失败身份验证,因为你不及格的凭据git呼叫正确。

由于您使用的是Git插件而不是shell命令,因此根本不需要使用withCredentials。您可以通过credentialsId直接git通话,这样的:

stage('checkout') { 
    git credentialsId: 'MyID', url: 'https://devMyCompany.org/stash/scm/test_automation.git', branch: 'development' 
} 
相关问题