1

我已将代码从本地机器推送到 azure repos。在推送代码时,时间头指向主分支。没关系。之后我创建了版本并发现了“git checkout error”。我检查了代理机器,我可以在这里看到它指向特定的提交而不是分支。我该如何解决这个问题?

在这里查看日志,

2020-02-04T07:34:23.2688328Z You are in 'detached HEAD' state. You can look around, make experimental
2020-02-04T07:34:23.2688360Z changes and commit them, and you can discard any commits you make in this
2020-02-04T07:34:23.2688390Z state without impacting any branches by performing another checkout.
2020-02-04T07:34:23.2688437Z 
2020-02-04T07:34:23.2688466Z If you want to create a new branch to retain commits you create, you may
2020-02-04T07:34:23.2688496Z do so (now or later) by using -b with the checkout command again. Example:
2020-02-04T07:34:23.2688518Z 
2020-02-04T07:34:23.2688565Z   git checkout -b <new-branch-name>
2020-02-04T07:34:23.2688588Z 
2020-02-04T07:34:23.2688616Z HEAD is now at 5c95b07 Added samplefile
2020-02-04T07:34:23.3208965Z An error occurred during download: System.InvalidOperationException: Git checkout failed with exit code: 1
   at Microsoft.VisualStudio.Services.Agent.Worker.Build.GitSourceProvider.GetSourceAsync(IExecutionContext executionContext, ServiceEndpoint endpoint, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.Services.Agent.Worker.Release.Artifacts.TfsGitArtifact.DownloadAsync(IExecutionContext executionContext, ArtifactDefinition artifactDefinition, String downloadFolderPath)
   at Microsoft.VisualStudio.Services.Agent.Worker.Release.ReleaseJobExtension.<>c__DisplayClass39_2.<<DownloadArtifacts>b__2>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.VisualStudio.Services.Agent.Worker.Release.RetryExecutor.ExecuteAsync(Func`1 action)
2020-02-04T07:34:23.3209166Z Retrying download...
2020-02-04T07:34:23.3211433Z Ensuring artifact folder C:\agent\vsts-agent-win-x64-2.163.1\_work\r2\a\_JHipsterDemoRepo exists and is clean.
2020-02-04T07:34:26.6696074Z Syncing repository: 3290da05-8551-4d0f-a00c-037d882d4835 (Git)
2020-02-04T07:34:26.6699057Z Prepending Path environment variable with directory containing 'git.exe'.
2020-02-04T07:34:26.6700464Z ##[command]git version
2020-02-04T07:34:26.6934186Z git version 2.21.0.windows.1
2020-02-04T07:34:26.6962266Z ##[command]git init "C:\agent\vsts-agent-win-x64-2.163.1\_work\r2\a\_JHipsterDemoRepo"
2020-02-04T07:34:26.7597056Z Initialized empty Git repository in C:/agent/vsts-agent-win-x64-2.163.1/_work/r2/a/_JHipsterDemoRepo/.git/
2020-02-04T07:34:26.7621586Z ##[command]git remote add origin https://218316@dev.azure.com/218316/CITS-Insights%20POC/_git/JHipsterDemoRepo
2020-02-04T07:34:26.7846491Z ##[command]git config gc.auto 0
2020-02-04T07:34:26.8167913Z ##[command]git config --get-all http.https://218316@dev.azure.com/218316/CITS-Insights%20POC/_git/JHipsterDemoRepo.extraheader
2020-02-04T07:34:26.8372843Z ##[command]git config --get-all http.proxy
2020-02-04T07:34:26.8590568Z ##[command]git -c http.extraheader="AUTHORIZATION: bearer ***" fetch --tags --prune --progress --no-recurse-submodules origin
2020-02-04T07:34:26.9953230Z remote: Azure Repos        
2020-02-04T07:34:26.9953340Z remote: We noticed you're using an older version of Git. For the best experience, upgrade to a newer version.
4

1 回答 1

1

Azure devops 错误:Git 签出失败,退出代码:1

根据错误日志:

Microsoft.VisualStudio.Services.Agent.Worker.Build.GitSourceProvider.GetSourceAsync

然后查看对应的源函数代码:GetSourceAsyncCheckout Submodule您的 repos 似乎有子模块,所以这个问题可能是由于在构建之前没有启用 optional 引起的。

checkoutSubmodules的默认值为False

要解决此问题,请尝试转到Add an artifact页面,然后启用可选Checkout submodules::

在此处输入图像描述

希望这可以帮助。

于 2020-02-05T07:36:52.650 回答