pau*_*rda 2 jenkins jenkins-pipeline
我使用 jenikins 管道作为代码来克隆位于私有 bitbucket 存储库(存储存储库)中的 git 项目。我使用此代码块在管道脚本中克隆项目。
node {
//checkout from master
stage 'checkout'
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'MyID', usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD']]) {
git url: 'https://paulrda@devMyCompany.org/stash/scm/test_automation.git' , branch: 'development'
}
}
Run Code Online (Sandbox Code Playgroud)
“MyID”是凭证 ID,我的用户名和密码是正确的。我将我的凭证保存在 jenkins 的全局凭证功能中。但是当我构建詹金斯任务时出现此错误。
错误:获取远程存储库“来源”时出错
hudson.plugins.git.GitException:无法从 https://paulrda@devMyCompany.org/stash/scm/test_automation.git 获取
在 hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:803)
在 hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1063)
在 hudson.plugins.git.GitSCM.checkout(GitSCM.java:1094)
在 org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:109)
在 org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:83)
在 org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:73)
在 org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
在 hudson.security.ACL.impersonate(ACL.java:221)
在 org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
在 java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
在 java.util.concurrent.FutureTask.run(FutureTask.java:266)
在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
在 java.lang.Thread.run(Thread.java:745)
引起:hudson.plugins.git.GitException:命令“git fetch --tags --progress https://paulrda@devMyCompany.org/stash/scm/test_automation.git +refs/heads/*:refs/remotes/origin /*”返回状态码128:
标准输出:
stderr:致命:“https://paulrda@devMyCompany.org/stash/scm/test_automation.git/”身份验证失败
在org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1745)
在org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1489)
在org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:64)
在 org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:315)
在 hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:801)
在我的 paulrda 帐户下的 mac 机器中,我可以使用 jenkins 管道脚本成功克隆我的项目,但是当我更改为另一个帐户并运行 jenkins 时,我收到此错误。我仍然不明白为什么我会收到这个错误。请提供这个问题的解决方案。
我的配置。
Jenkins 版本:2.19.2
凭证插件:2.1.8
Git 插件:3.0.0
Git 客户端插件:2.1.0
它无法进行身份验证,因为您没有正确地将凭据传递给调用git。
由于您使用的是 Git 插件而不是 shell 命令,因此根本没有必要使用withCredentials。您可以credentialsId直接传递git调用,如下所示:
stage('checkout') {
git credentialsId: 'MyID', url: 'https://devMyCompany.org/stash/scm/test_automation.git', branch: 'development'
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15196 次 |
| 最近记录: |