我正在使用在Windows自托管代理上运行的Azure Pipeline。我的目标是运行自动化测试,并在Azure Pipeline 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 streams have closed for tool“错误,并有关于".NET 5...”的警告,项目可以使用安装在我的代理上的DotNet 3进行编译,会不会是这个问题?
##[debug]Exit code 1 received from tool 'C:\Program Files\dotnet\dotnet.exe'
##[debug]STDIO streams have closed for tool 'C:\Program Files\dotnet\dotnet.exe'
##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1
##[debug]Processed: ##vso[task.issue type=error;]Error: The process 'C:\Program Files\dotnet\dotnet.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\_work\11\s\src\API.Test.Core\API.Test.Core.csproj
##vso[task.issue type=error;]Dotnet command failed with non-zero exit code on the following projects : C:\Agent\_work\11\s\src\API.Test.Core\API.Test.Core.csproj
##[debug]Processed: ##vso[task.complete result=Failed;]Dotnet command failed with non-zero exit code on the following projects : C:\Agent\_work\11\s\src\API.Test.Core\API.Test.Core.csproj
##[section]Finishing: Run testsPublishTestResults@2任务以绿色结束,但出现以下错误:"STDIO streams have closed for tool“和:"Moved Temporarily”
##[debug]C:\Agent\_work\_tasks\PublishTestResults_0b0f0***9b1\2.180.0\modules\TestResultsPublisher.exe arg: ["@C:\\Agent\\_work\\_temp\\5f4d53***2b.txt"]
##[debug]exec tool: C:\Agent\_work\_tasks\PublishTestResults_0b0***9b1\2.180.0\modules\TestResultsPublisher.exe
##[debug]arguments:
##[debug] @C:\Agent\_work\_temp\5f4d***bf2b.txt
[command]C:\Agent\_work\_tasks\PublishTestResults_0b0f***f9b1\2.180.0\modules\TestResultsPublisher.exe @C:\Agent\_work\_temp\5f4d***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\_tasks\PublishTestResults_0b0f0***f9b1\2.180.0\modules\TestResultsPublisher.exe'
##[debug]STDIO streams have closed for tool
'C:\Agent\_work\_tasks\PublishTestResults_0***9b1\2.180.0\modules\TestResultsPublisher.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\_work\11\TestResults\***_2021-04-12_14_19_44.trx'
##[debug]Setting run start and finish times.
##[debug]Attachment location: C:\Agent\_work\11\TestResults\***_2021-04-12_14_19_44\In
##[debug]Adding run level attachment: C:\Agent\_work\11\TestResults\***_2021-04-12_14_19_44\In\***\***-1_2021-04-12.14_19_37.coverage
##[debug]Processed: ##vso[results.publish type=VSTest;mergeResults=false;publishRunAttachments=true;resultFiles=E:\Agent\_work\11\TestResults\AzureBuild_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 "***\s\src\API.Test.Core\API.Test.Core.csproj" --logger trx --results-directory "***\TestResults" --collect "Code coverage"我得到了与管道相同的结果:
Results File: ***\TestResults\***_2021-04-13_14_05_46.trx
Attachments:
***\TestResults\d91***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 Files\dotnet\dotnet.exe'
##[debug]STDIO streams have closed for tool 'C:\Program Files\dotnet\dotnet.exe'
##[error]Error: The process 'C:\Program Files\dotnet\dotnet.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 Files\dotnet\dotnet.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_07\In
##[debug]Adding run level attachment: C:\Agent\_work\_temp\***-04-15_18_56_07\In\***\***-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\_work\11\s\src\API.Test.Core\API.Test.Core.csproj
##[debug]Processed: ##vso[task.issue type=error;]Dotnet command failed with non-zero exit code on the following projects : C:\Agent\_work\11\s\src\API.Test.Core\API.Test.Core.csproj
##[debug]Processed: ##vso[task.complete result=Failed;]Dotnet command failed with non-zero exit code on the following projects : C:\Agent\_work\11\s\src\API.Test.Core\API.Test.Core.csproj
Async Command Start: Publish test results
##[warning]Failed to publish test results: Moved Temporarily
Async Command End: Publish test results我也尝试了从结果目录命令行添加这个选项:"--logger trx -- DotNet -directory“C:\Agent_work_temp”,但是这能将报告上传回管道吗?在我看来是不可能的。非常感谢你的帮助。
发布于 2021-04-13 17:36:18
为了缩小问题的范围,您可以尝试以下项目:
DotNetCoreCLI中的test命令无法识别feedRestore或vstsFeed参数,当隐式NuGet.config步骤运行时,以这种方式指定的提要将不会包含在生成的restore文件中。建议使用显式dotnet restore步骤来恢复软件包。restore命令遵循feedRestore和vstsFeed参数。https://stackoverflow.com/questions/67059558
复制相似问题