Jenkins Git插件 - 401

9
我尝试了各种不同的方法,但无法让Jenkins与Git配合良好。
我已设置了我的SSH密钥,并验证了我可以通过SSH连接到GitHub并收到消息。我还尝试过不带.git扩展名,尝试过在URL中包含用户名、用户名和密码或根本没有用户名/密码。但无论如何都失败了。
我还尝试过使用管理员用户和普通的推送/拉取用户。
我正在尝试访问一个位于“组织”中的Git存储库,但我所在的团队有访问权限。
Cloning repository origin
ERROR: Error cloning remote repo 'origin' : Could not clone https://github.com/xxx/xx
hudson.plugins.git.GitException: Could not clone https://github.com/xxx/xx
    at hudson.plugins.git.GitAPI.clone(GitAPI.java:245)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1073)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1014)
    at hudson.FilePath.act(FilePath.java:788)
    at hudson.FilePath.act(FilePath.java:770)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1014)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1195)
    at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:579)
    at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:468)
    at hudson.model.Run.run(Run.java:1408)
    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:478)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:238)
Caused by: hudson.plugins.git.GitException: Error performing command: git clone --progress -o origin https://github.com/xxxx/xx /var/lib/jenkins/jobs/test/workspace
Command "git clone --progress -o origin https://github.com/xxxx/xx /var/lib/jenkins/jobs/test/workspace" returned status code 128: Initialized empty Git repository in /var/lib/jenkins/jobs/test/workspace/.git/
error: The requested URL returned error: 401 while accessing https://github.com/xxxx/xx/info/refs

是的,它是一个私有仓库。 - Douglas Ferguson
2个回答

13
尝试使用r/w地址和ssh密钥克隆私有存储库: git@github.com:xxx/xx.git

那个完美地运作。我还不到15岁,所以不能顶这个答案。 - Douglas Ferguson
现在你是;) 你也可以将答案标记为正确吗?谢谢。 - iltempo

1
如果您通过 URL 传递凭据,请确保它们是 URL 编码的。还要确保您使用基本身份验证。

是的..我没有任何需要编码的字符。奇怪的是,我甚至无法从命令行运行该命令。我可以在我的开发机上从命令行推送/拉取。我可以正常地推送和拉取,但如果我运行那个克隆命令,它就会崩溃。 - Douglas Ferguson

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接