Azure 测试管道,2 个错误:STDIO 流已关闭,用于工具和 &&暂时移动



我正在Windows自托管代理上运行Azure管道。我的目标是运行自动化测试,并在Azure管道UI中查看结果。

我的两个任务都有错误消息,这是我的管道:

stages:
- stage: TEST
jobs:
- job: Test
steps:
- task: NuGetAuthenticate@0
inputs:
nuGetServiceConnections: 'NuGetSvcConnec'
forceReinstallCredentialProvider: true
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
echo '##vso[task.setvariable variable=TASKLIB_TEST_TOOLRUNNER_EXITDELAY]90000'
- task: DotNetCoreCLI@2
displayName: 'Run tests'
inputs:
command: test
projects: 'src/API.Test.Core/API.Test.Core.csproj'
arguments: '--logger trx --results-directory $(Agent.BuildDirectory)TestResults --collect "Code coverage"'
testRunTitle: 'Tests'
feedsToUse: 'select'
vstsFeed: '33706***8878fd368'
includeNuGetOrg: false
publishTestResults: false
- task: PublishTestResults@2
displayName: 'Publish Test Results'
condition: failed() 
inputs:
testResultsFormat: 'VSTest'
testResultsFiles: '*.trx'
searchFolder: '$(Agent.BuildDirectory)TestResults'

我找到了一个变通方法来设置TASKLIB_TEST_TOOLRUNNER_EXITDELAY环境变量,但要么是我的脚本做错了,要么对我的情况没有帮助。

DotNetCoreCLI@2任务失败;STDIO流已经关闭;错误并且存在关于"的警告;。NET 5…";,该项目确实使用安装在我的代理上的DotNet3进行编译,这可能是问题所在吗?

##[debug]Exit code 1 received from tool 'C:Program Filesdotnetdotnet.exe'
##[debug]STDIO streams have closed for tool 'C:Program Filesdotnetdotnet.exe'
##[error]Error: The process 'C:Program Filesdotnetdotnet.exe' failed with exit code 1
##[debug]Processed: ##vso[task.issue type=error;]Error: The process 'C:Program Filesdotnetdotnet.exe' failed with exit code 1
##[warning].NET 5 has some compatibility issues with older Nuget versions(<=5.7)...
##[debug]task result: Failed
##[error]Dotnet command failed with non-zero exit code on the following projects : C:Agent_work11ssrcAPI.Test.CoreAPI.Test.Core.csproj
##vso[task.issue type=error;]Dotnet command failed with non-zero exit code on the following projects : C:Agent_work11ssrcAPI.Test.CoreAPI.Test.Core.csproj
##[debug]Processed: ##vso[task.complete result=Failed;]Dotnet command failed with non-zero exit code on the following projects : C:Agent_work11ssrcAPI.Test.CoreAPI.Test.Core.csproj
##[section]Finishing: Run tests

PublishTestResults@2任务以绿色结束,但存在关于以下内容的错误:;STDIO流已经关闭;以及:";暂时移动";

##[debug]C:Agent_work_tasksPublishTestResults_0b0f0***9b12.180.0modulesTestResultsPublisher.exe arg: ["@C:\Agent\_work\_temp\5f4d53***2b.txt"]
##[debug]exec tool: C:Agent_work_tasksPublishTestResults_0b0***9b12.180.0modulesTestResultsPublisher.exe
##[debug]arguments:
##[debug]   @C:Agent_work_temp5f4d***bf2b.txt
[command]C:Agent_work_tasksPublishTestResults_0b0f***f9b12.180.0modulesTestResultsPublisher.exe @C:Agent_work_temp5f4d***bf2b.txt
##[debug]Exception while fetching feature flag value
##[debug]One or more errors occurred.
##[debug]Exit code 20000 received from tool 'C:Agent_work_tasksPublishTestResults_0b0f0***f9b12.180.0modulesTestResultsPublisher.exe'
##[debug]STDIO streams have closed for tool 
'C:Agent_work_tasksPublishTestResults_0***9b12.180.0modulesTestResultsPublisher.exe'
##[debug]Exit code of TestResultsPublisher: 20000
##[debug]Failed to get FF TestManagement.Server.UsePublishTestResultsLibInAgent Value.
Unable to get the FF: TestManagement.Server.EnablePublishToTcmServiceDirectlyFromTask. Reason: One or more errors occurred. (Moved Temporarily)
##[debug]Failed to get FF TestManagement.PTR.CalculateTestRunSummary Value.
##[debug]Reading test results from file 'C:Agent_work11TestResults***_2021-04-12_14_19_44.trx'
##[debug]Setting run start and finish times.
##[debug]Attachment location: C:Agent_work11TestResults***_2021-04-12_14_19_44In
##[debug]Adding run level attachment: C:Agent_work11TestResults***_2021-04-12_14_19_44In******-1_2021-04-12.14_19_37.coverage
##[debug]Processed: ##vso[results.publish type=VSTest;mergeResults=false;publishRunAttachments=true;resultFiles=E:Agent_work11TestResultsAzureBuild_Svc_DEVOPS-DLP-1_2021-04-12_14_19_44.trx;failTaskOnFailedTests=false;testRunSystem=VSTS - PTR;]
##[debug]task result: Succeeded
##[debug]Processed: ##vso[task.complete result=Succeeded;]
##[debug]Release.ReleaseUri=undefined
##[debug]Release.ReleaseId=undefined
##[debug]Build.BuildUri=vstfs:///Build/Build/9933
##[debug]Build.Buildid=9933
##[warning]Failed to publish test results: Moved Temporarily
##[debug]Processed: ##vso[telemetry.publish area=TestExecution;feature=PublishTestResultsTask]{"builduri":"vstfs:///Build/Build/9933","buildid":"9933","osType":"Windows_NT","testRunner":"VSTest","failTaskOnFailedTests":"false","mergeResultsUserPreference":"false","config":null,"platform":null,"testResultsFilesCount":1,"dotnetVersion":"5.0.100","subFeature":"publishTestResultsTaskConsolidatedCiEvent"}
##[section]Async Command Start: Publish test results
##[section]Async Command End: Publish test results

##############更新1####################

我在本地运行:

"dotnet.exe" test "***ssrcAPI.Test.CoreAPI.Test.Core.csproj" --logger trx --results-directory "***TestResults" --collect "Code coverage"

我得到了与管道相同的结果:

Results File: ***TestResults***_2021-04-13_14_05_46.trx
Attachments:
***TestResultsd91***7774c***_2021-04-13.14_05_42.coverage
Failed!  - Failed:    42, Passed:     0, Skipped:     0, Total:    42, Duration: 2 s - API.Test.Core.dll (netcoreapp3.1)

命令停止在管道中继续的位置:

##[debug]Exit code 1 received from tool 'C:Program Filesdotnetdotnet.exe'
##[debug]STDIO streams have closed for tool 'C:Program Filesdotnetdotnet.exe'
##[error]Error: The process 'C:Program Filesdotnetdotnet.exe' failed with exit code 1

我不知道我可以在本地做什么来复制这个动作,你能帮我吗?

从一开始,似乎很难将测试和覆盖率结果发送回Azure DevOps,知道是什么原因造成的吗?我在代理后面运行,但我确实提供了凭据和代理值。。。

我会考虑重新安装代理。。。谢谢

##############更新2####################

我更新了我的管道:

- job: Test
steps:
- task: NuGetAuthenticate@0
inputs:
nuGetServiceConnections: 'MyServiceConnection'
forceReinstallCredentialProvider: true
- task: PowerShell@2
displayName: 'Set Env variable to prevent error: ##[debug]STDIO streams have closed for tool C:Program Filesdotnetdotnet.exe'
inputs:
targetType: 'inline'
script: |
echo '##vso[task.setvariable variable=TASKLIB_TEST_TOOLRUNNER_EXITDELAY]90000'
- task: DotNetCoreCLI@2
displayName: 'Restore'
inputs:
command: restore
projects: 'src/API.Test.Core/API.Test.Core.csproj'
feedsToUse: 'select'
vstsFeed: '33706e***68'
includeNuGetOrg: false
- task: DotNetCoreCLI@2
displayName: 'Run tests'
inputs:
command: test
projects: 'src/API.Test.Core/API.Test.Core.csproj'
arguments: '--collect "Code coverage"'
includeNuGetOrg: false
publishTestResults: true

我得到了这个日志:

##[debug]adjustedPattern: 'C:Agent_work_temp**/*.trx'
##[debug]1 final results
##[debug]Failed to get FF TestManagement.Server.UsePublishTestResultsLibInAgent Value.
Unable to get the FF: TestManagement.Server.EnablePublishToTcmServiceDirectlyFromTask. Reason: One or more errors occurred. (Moved Temporarily)
##[debug]Failed to get FF TestManagement.PTR.CalculateTestRunSummary Value.
##[debug]Reading test results from file 'C:Agent_work_temp***-04-15_18_56_07.trx'
##[debug]Setting run start and finish times.
##[debug]Attachment location: C:Agent_work_temp***-04-15_18_56_07In
##[debug]Adding run level attachment: C:Agent_work_temp***-04-15_18_56_07In******-04-15.18_56_00.coverage
##[debug]Total test results: 42
##[debug]Processed: ##vso[results.publish type=VSTest;mergeResults=false;publishRunAttachments=true;resultFiles=C:Agent_work_temp***-04-15_18_56_07.trx;testRunSystem=VSTS - dotnet;]
##[debug]task result: Failed
##[error]Dotnet command failed with non-zero exit code on the following projects : C:Agent_work11ssrcAPI.Test.CoreAPI.Test.Core.csproj
##[debug]Processed: ##vso[task.issue type=error;]Dotnet command failed with non-zero exit code on the following projects : C:Agent_work11ssrcAPI.Test.CoreAPI.Test.Core.csproj
##[debug]Processed: ##vso[task.complete result=Failed;]Dotnet command failed with non-zero exit code on the following projects : C:Agent_work11ssrcAPI.Test.CoreAPI.Test.Core.csproj
Async Command Start: Publish test results
##[warning]Failed to publish test results: Moved Temporarily
Async Command End: Publish test results

我还从DotNet命令行尝试,添加了以下选项:"--logger trx—结果目录";C: \Agent_work_temp"quot;但这能将报告上传回管道吗?对我来说似乎不可能。。。非常感谢你的帮助。

为了缩小问题范围,您可以尝试以下项目:

  1. DotNetCoreCLI中的test命令无法识别feedRestorevstsFeed参数,并且在运行隐式restore步骤时,以这种方式指定的提要将不会包含在生成的NuGet.config文件中。建议使用显式dotnet restore步骤来恢复程序包。restore命令尊重feedRestorevstsFeed参数。

  2. 由于您使用的是Windows自托管代理,请尝试登录到代理计算机,然后手动运行.NetCore CLI,查看结果如何。

  3. 请检查代理版本并升级到最新版本,然后尝试重新启动生成代理服务以查看结果。

  4. 尝试配置一个新的代理,看看结果如何。

最新更新