【发布时间】:2020-12-03 09:42:49
【问题描述】:
我在 Azure DevOps 中有一个发布管道,其中一个步骤是运行使用 Nunit 设计的测试。
任务的 YAML:
steps:
- task: DotNetCoreCLI@2
displayName: 'Run Tests'
inputs:
command: custom
projects: '**/a/Tests.dll'
custom: vstest
arguments: '--logger:"trx;LogFileName=test.trx" '
在我的测试设置中,我使用以下方法从环境变量中检索一些设置:
private static IConfiguration InitConfiguration()
{
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddEnvironmentVariables()
.Build();
return config;
}
我还将环境变量的值存储在 Azure DevOps 变量组中。
当我的变量未锁定时一切正常,它们被成功检索并且测试运行正常。
但是,当我锁定秘密时,它们的值变为空,因此我的测试无法运行。
为了从我的应用程序中正确读取锁定的变量,我应该进行哪些更改。
【问题讨论】:
标签: .net-core azure-devops azure-pipelines nunit