用于在 Build Pipeline VSTS 中添加 timeoutinminutes 的 Yaml 脚本
Yaml script for adding timeoutinminutes in Build Pipeline VSTS
当我构建我的测试解决方案(一组单元测试用例)时,出现以下错误,需要在下面的 yaml 脚本中添加 timeoutinminutes。
[Error 1]
The job running on agent Hosted Agent ran longer than the maximum time of 60 minutes. For more information, see https://go.microsoft.com/fwlink/?linkid=2077134
在下面找到yaml脚本:
# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/**.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Debug'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
timeoutInMinutes: 1200
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
runInParallel: true
testSelector: 'testAssemblies'
testAssemblyVer2: |
**\*test*.dll
!**\*TestAdapter.dll
!**\obj\**
searchFolder: '$(System.DefaultWorkingDirectory)'
我想您感到困惑的应该是为什么您将 timeoutInMinutes
指定为 1200
,以及为什么仍然面临错误:
"The job running on agent Hosted Agent ran longer than the maximum
time of 60 minutes."
正如D.J所说,错误信息中的link已经给你解释了。
你的项目应该是私有的,对吧?如果是这样,那么您就无法避免私有项目的托管代理的限制。
Capabilities and limitations of Microsoft-hosted agents:
Public project: 10 free Microsoft-hosted parallel jobs that can run for up to 360 minutes (6 hours) each time
Private project: One free parallel job that can run for up to 60 minutes each time
虽然您将超时指定为 1200 分钟,但不幸的是,它无法超越服务器的限制。
让您的测试不受超时限制的最佳解决方案是install and use private agent。
或者您认为 360 分钟对您来说足够了,那么您可以尝试将项目更改为 public。但如果您认为脚本和存储库对您来说非常私密,我不推荐这种方式。
当我构建我的测试解决方案(一组单元测试用例)时,出现以下错误,需要在下面的 yaml 脚本中添加 timeoutinminutes。
[Error 1] The job running on agent Hosted Agent ran longer than the maximum time of 60 minutes. For more information, see https://go.microsoft.com/fwlink/?linkid=2077134
在下面找到yaml脚本:
# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/**.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Debug'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
timeoutInMinutes: 1200
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
runInParallel: true
testSelector: 'testAssemblies'
testAssemblyVer2: |
**\*test*.dll
!**\*TestAdapter.dll
!**\obj\**
searchFolder: '$(System.DefaultWorkingDirectory)'
我想您感到困惑的应该是为什么您将 timeoutInMinutes
指定为 1200
,以及为什么仍然面临错误:
"The job running on agent Hosted Agent ran longer than the maximum time of 60 minutes."
正如D.J所说,错误信息中的link已经给你解释了。
你的项目应该是私有的,对吧?如果是这样,那么您就无法避免私有项目的托管代理的限制。
Capabilities and limitations of Microsoft-hosted agents:
Public project: 10 free Microsoft-hosted parallel jobs that can run for up to 360 minutes (6 hours) each time
Private project: One free parallel job that can run for up to 60 minutes each time
虽然您将超时指定为 1200 分钟,但不幸的是,它无法超越服务器的限制。
让您的测试不受超时限制的最佳解决方案是install and use private agent。
或者您认为 360 分钟对您来说足够了,那么您可以尝试将项目更改为 public。但如果您认为脚本和存储库对您来说非常私密,我不推荐这种方式。