我试图将Jenkins的工作从SVN转换到新的TFS-GIT存储库(在我们的组织内托管)。
我指定了Git存储库
http://thehost:8080/tfs/path/_git/reponame
詹金斯告诉我
Failed to connect to repository : Failed to connect to http://thehost:8080/tfs/path/_git/reponame (status = 401)
我可以使用相同的repo URL从linux命令行成功运行Git,并且它不会提示输入密码(使用.git-credentials的值)。
配置
Jenkins服务器
TFS-GIT服务器
在作业控制台中出现了同样的错误:
Building in workspace /var/lib/jenkins/workspace/myproject
Checkout:myproject / /var/lib/jenkins/workspace/myproject - hudson.remoting.LocalChannel@3edcc1f9
Using strategy: Default
Fetching changes from 1 remote Git repository
Fetching upstream changes from origin
ERROR: Problem fetching from origin / origin - could be unavailable. Continuing anyway
hudson.plugins.git.GitException: Failed to connect to http://thehost:8080/tfs/path/_git/reponame (status = 401)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.checkCredentials(CliGitAPIImpl.java:1911)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1105)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1073)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1064)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.fetch(CliGitAPIImpl.java:286)
at hudson.plugins.git.GitAPI.fetch(GitAPI.java:235)
at hudson.plugins.git.GitAPI.fetch(GitAPI.java:239)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:791)
at hudson.plugins.git.GitSCM.access$000(GitSCM.java:58)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:983)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:948)
at hudson.FilePath.act(FilePath.java:914)
at hudson.FilePath.act(FilePath.java:887)
at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:948)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1114)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1411)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:651)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:560)
at hudson.model.Run.execute(Run.java:1670)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:519)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:231)
ERROR: Could not fetch from any repository
java.io.IOException: Could not fetch from any repository
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:992)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:948)
at hudson.FilePath.act(FilePath.java:914)
at hudson.FilePath.act(FilePath.java:887)
at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:948)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1114)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1411)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:651)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:560)
at hudson.model.Run.execute(Run.java:1670)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:519)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:231)
用户名的格式为DOMAIN \ username。
我已经尝试了一些没有结果的方法。
感谢您的建议。
更新
我通过将SCM设置为" none",使用"定期构建"来使Jenkins构建工作。而不是"轮询SCM",并添加一个预构建步骤(Execute Shell),它从Git中检出代码:
rm -rf $WORKSPACE/* $WORKSPACE/.git
/usr/local/bin/git clone -b branch --single-branch http://DOMAIN\\username:xxxxx@thehost:8080/tfs/path/_git/reponame $WORKSPACE
我仍然非常欢迎任何可以让我使用" Poll SCM"而不是定期建设。似乎Git Client可能不喜欢DOMAIN \ username-style名称(?)
答案 0 :(得分:3)
我发现如何解决这个问题经过多次绞尽脑汁......默认情况下,TFS使用NTLM与基本身份验证进行身份验证,这是git理解的内容。解决这个问题的方法是通过TFS允许基本身份验证。见http://almcrank.com/jenkins-build-with-a-git-repository-tfs/
我最初这样做了,没有运气,经过多次试验和错误后发现我需要另外点击"编辑"在IIS管理面板的右侧,而基本身份验证"已被选中,我必须放入我的默认域名。如果没有这个,似乎没有适当地理解反斜杠(即DOMAIN \ user)。然后在Jenkins中,确保您的凭证正在传递> 域。
要考虑的另一件事是Git没有本地方式来存储HTTP凭据。所以你留下了一些选择: