0

我们想将 TFS2017 连接到 GitHub for Enterprise。

  • 向“外部 Git”添加了一个新的服务端点
  • 使用我的 ghe 用户名和个人访问令牌配置它
  • 添加了新的构建定义
  • 选择的外部git,以及刚刚配置的服务
  • 输入存储库名称(没有下拉菜单,尝试了各种格式,包括完整的 https://ghe.mycompany.com/myUsername/myTestRepository.git
  • 触发了新的构建

当我们尝试克隆时出现错误。错误发生在“获取源”步骤 (1_Get_sources.txt)

2016-11-21T13:31:20.4836373Z Syncing repository: https://ghe.mycompany.com/********/myTestRepository.git (Git)
2016-11-21T13:31:20.5326404Z Starting clone
2016-11-21T13:31:21.0286690Z ##[error]LibGit2Sharp.LibGit2SharpException: Request failed with status code: 404
2016-11-21T13:31:21.0296729Z ##[error]   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
2016-11-21T13:31:21.0306726Z ##[error]   at LibGit2Sharp.Core.Proxy.git_clone(String url, String workdir, GitCloneOptions& opts)
2016-11-21T13:31:21.0316723Z ##[error]   at LibGit2Sharp.Repository.Clone(String sourceUrl, String workdirPath, CloneOptions options)
2016-11-21T13:31:21.0336678Z ##[error]   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.CloneRepository(String repositoryPath, Uri repositoryUrl, Boolean checkoutSubmodules, String username, String password)
2016-11-21T13:31:21.0346735Z ##[error]   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.SyncRepository(Uri repositoryUrl, String rootPath, Boolean cleanRepository, Boolean checkoutSubmodules, String sourceVersion, String username, String password)
2016-11-21T13:31:21.0356736Z ##[error]   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.SyncRepository(ITaskEndpoint endpoint, String rootPath, Boolean cleanRepository, Boolean checkoutSubmodules, String sourceVersion)
2016-11-21T13:31:21.0366732Z ##[error]   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.SyncAndCheckout(Boolean cleanRepository, String sourceBranch, String sourceVersion, Boolean checkoutSubmodules, CancellationToken cancellationToken)
2016-11-21T13:31:21.0376729Z ##[error]   at Microsoft.TeamFoundation.DistributedTask.Plugin.Build.GitSourceProvider.<>c__DisplayClass3_0.<PrepareRepositoryAsync>b__0()

在本地(在 TFS 服务器上),我们可以使用 powershell 进行克隆,并在构建步骤中执行脚本让我们验证是否使用了相同的代理设置。

下面是来自 _diag 文件夹的更多调试信息

    11:35:23.072987 BaseLogger.LogConsoleMessage(scope.JobId = af970025-e4bc-4692-a708-bbe734745370, message = Syncing repository: https://ghe.mycompany.com/********/myTestRepository.git (Git))
11:35:23.076124 BaseLogger.LogConsoleMessage(scope.JobId = af970025-e4bc-4692-a708-bbe734745370, message = repository url=https://ghe.mycompany.com/api/v3)
11:35:23.078235 BaseLogger.LogConsoleMessage(scope.JobId = af970025-e4bc-4692-a708-bbe734745370, message = checkoutSubmodules=False)
11:35:23.087627 Syncing and checking out sources.
11:35:23.087627 rootPath=C:\TfsBuildAgents\Agent-smi-build01\_work\22\s
11:35:23.087627 cleanRepository=True
11:35:23.087627 sourceBranch=master
11:35:23.087627 sourceVersion=
11:35:23.088628 sourcesToBuild=refs/remotes/origin/master
11:35:23.092875 Checking if the repo on disk matches the expected repository URL.
11:35:23.092875 gitRepoFolder=C:\TfsBuildAgents\Agent-smi-build01\_work\22\s
11:35:23.092875 expectedRepositoryUrl=https://ghe.mycompany.com/api/v3
11:35:23.120701 Unable to determine whether the existing repo matches. Suppressing the exception and treating the repo as if it doesn't match. For verbose purposes only, the exception is: LibGit2Sharp.RepositoryNotFoundException: Path 'C:\TfsBuildAgents\Agent-smi-build01\_work\22\s' doesn't point at a valid Git repository or workdir.
   at LibGit2Sharp.Core.Proxy.git_repository_open(String path)
   at LibGit2Sharp.Repository..ctor(String path, RepositoryOptions options, RepositoryRequiredParameter requiredParameter)
   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.IsExpectedRepository(String gitRepoFolder, Uri expectedRepositoryUrl)
11:35:23.127765 BaseLogger.LogConsoleMessage(scope.JobId = af970025-e4bc-4692-a708-bbe734745370, message = Starting clone)
11:35:23.133909 Process logging event with task handler.
11:35:23.613344 ---------------------------------------------------------------------------
11:35:23.615482 LibGit2Sharp.LibGit2SharpException: Request failed with status code: 404

11:35:23.615482    at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)

11:35:23.615482    at LibGit2Sharp.Core.Proxy.git_clone(String url, String workdir, GitCloneOptions& opts)

11:35:23.615482    at LibGit2Sharp.Repository.Clone(String sourceUrl, String workdirPath, CloneOptions options)

11:35:23.615482    at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.CloneRepository(String repositoryPath, Uri repositoryUrl, Boolean checkoutSubmodules, String username, String password)

11:35:23.615482    at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.SyncRepository(Uri repositoryUrl, String rootPath, Boolean cleanRepository, Boolean checkoutSubmodules, String sourceVersion, String username, String password)

11:35:23.616553    at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.SyncRepository(ITaskEndpoint endpoint, String rootPath, Boolean cleanRepository, Boolean checkoutSubmodules, String sourceVersion)

11:35:23.616553    at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.SyncAndCheckout(Boolean cleanRepository, String sourceBranch, String sourceVersion, Boolean checkoutSubmodules, CancellationToken cancellationToken)

11:35:23.616553    at Microsoft.TeamFoundation.DistributedTask.Plugin.Build.GitSourceProvider.<>c__DisplayClass3_0.<PrepareRepositoryAsync>b__0()
11:35:23.616553    at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)

11:35:23.616553    at LibGit2Sharp.Core.Proxy.git_clone(String url, String workdir, GitCloneOptions& opts)

11:35:23.616553    at LibGit2Sharp.Repository.Clone(String sourceUrl, String workdirPath, CloneOptions options)

11:35:23.616553    at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.CloneRepository(String repositoryPath, Uri repositoryUrl, Boolean checkoutSubmodules, String username, String password)

11:35:23.616553    at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.SyncRepository(Uri repositoryUrl, String rootPath, Boolean cleanRepository, Boolean checkoutSubmodules, String sourceVersion, String username, String password)

11:35:23.616553    at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.SyncRepository(ITaskEndpoint endpoint, String rootPath, Boolean cleanRepository, Boolean checkoutSubmodules, String sourceVersion)

11:35:23.616553    at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.SyncAndCheckout(Boolean cleanRepository, String sourceBranch, String sourceVersion, Boolean checkoutSubmodules, CancellationToken cancellationToken)

11:35:23.616553    at Microsoft.TeamFoundation.DistributedTask.Plugin.Build.GitSourceProvider.<>c__DisplayClass3_0.<PrepareRepositoryAsync>b__0()
11:35:23.617555 ---------------------------------------------------------------------------
11:35:23.618654 Process logging event with task handler.
11:35:23.623821 BaseLogger.LogConsoleMessage(scope.JobId = af970025-e4bc-4692-a708-bbe734745370, message = ##[error]LibGit2Sharp.LibGit2SharpException: Request failed with status code: 404)
11:35:23.624910 BaseLogger.LogConsoleMessage(scope.JobId = af970025-e4bc-4692-a708-bbe734745370, message = ##[error]   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result))
11:35:23.625909 BaseLogger.LogConsoleMessage(scope.JobId = af970025-e4bc-4692-a708-bbe734745370, message = ##[error]   at LibGit2Sharp.Core.Proxy.git_clone(String url, String workdir, GitCloneOptions& opts))
11:35:23.626974 BaseLogger.LogConsoleMessage(scope.JobId = af970025-e4bc-4692-a708-bbe734745370, message = ##[error]   at LibGit2Sharp.Repository.Clone(String sourceUrl, String workdirPath, CloneOptions options))
11:35:23.627973 BaseLogger.LogConsoleMessage(scope.JobId = af970025-e4bc-4692-a708-bbe734745370, message = ##[error]   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.CloneRepository(String repositoryPath, Uri repositoryUrl, Boolean checkoutSubmodules, String username, String password))
11:35:23.629042 BaseLogger.LogConsoleMessage(scope.JobId = af970025-e4bc-4692-a708-bbe734745370, message = ##[error]   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.SyncRepository(Uri repositoryUrl, String rootPath, Boolean cleanRepository, Boolean checkoutSubmodules, String sourceVersion, String username, String password))
11:35:23.630112 BaseLogger.LogConsoleMessage(scope.JobId = af970025-e4bc-4692-a708-bbe734745370, message = ##[error]   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.SyncRepository(ITaskEndpoint endpoint, String rootPath, Boolean cleanRepository, Boolean checkoutSubmodules, String sourceVersion))
11:35:23.631180 BaseLogger.LogConsoleMessage(scope.JobId = af970025-e4bc-4692-a708-bbe734745370, message = ##[error]   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.Core.GitHelper.SyncAndCheckout(Boolean cleanRepository, String sourceBranch, String sourceVersion, Boolean checkoutSubmodules, CancellationToken cancellationToken))
11:35:23.632188 BaseLogger.LogConsoleMessage(scope.JobId = af970025-e4bc-4692-a708-bbe734745370, message = ##[error]   at Microsoft.TeamFoundation.DistributedTask.Plugin.Build.GitSourceProvider.<>c__DisplayClass3_0.<PrepareRepositoryAsync>b__0())
11:35:23.634183 Process logging event with task handler.
11:35:23.638350 BaseLogger.LogStatus(scope.JobId = af970025-e4bc-4692-a708-bbe734745370, scope.TimelineRecordId = 2fd7ca75-f01d-4906-bf39-7c8d66a1df7f, record.Name = )
11:35:23.649716 BaseLogger.LogAttachment(scope.JobId = af970025-e4bc-4692-a708-bbe734745370, type = DistributedTask.Core.Log, name = Get sources, path = C:\TfsBuildAgents\Agent-smi-build01\_diag\w7ac045c8-3285-4be2-b993-b542da560c11.log)
11:35:23.658368 ---------------------------------------------------------------------------
11:35:23.660442 System.AggregateException: One or more errors occurred. ---> Microsoft.TeamFoundation.DistributedTask.Agent.Common.AgentExecutionTerminationException: Prepare repository failed with exception. ---> LibGit2Sharp.LibGit2SharpException: Request failed with status code: 404

知道如何调试这个,或者我们可以尝试什么吗?

4

1 回答 1

1

根据页面,您无法使用 TFS 2017 连接到 Github Enterprise。如果情况发生了变化,请告诉我,因为我希望能够这样做!

于 2018-04-27T22:41:52.297 回答