Azure DevOps构建中的秘密(dotnet核心) [英] Secrets in Azure DevOps builds (dotnet core)

查看:68
本文介绍了Azure DevOps构建中的秘密(dotnet核心)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目中有许多测试是作为构建的一部分运行的。其中一些测试是集成测试,需要一组用户名/密码凭据才能运行测试。

I have a number of tests in my project which are run as part of the build. Some of those tests are integration tests which need a username/password set of credentials in order to run the tests.

我想将这些凭据保留在源代码之外,因此在我的本地计算机上,我将它们设置为用户机密,在服务器上,它们是环境变量。

I want to keep these credentials out of the source code so on my local machine I have set them up as user secrets and on the server they are environment variables. The deployments are working just fine with this arrangement.

我的问题是将测试作为构建的一部分运行。测试没有提供任何登录凭据,因此由于身份验证问题而失败。我如何提供这些值而不将其添加到appsettings.json文件中?

My problem is running the tests as part of the build. The tests are not being fed with any login credentials and therefore are failing with authentication issues. How do I supply these values without adding them to the appsettings.json files?

我正在运行一个dotnet核心项目,并且具有标准的Azure DevOps构建模板。

I am running a dotnet core project and have a standard Azure DevOps build template.

谢谢!

推荐答案

在构建中声明的非秘密变量会自动打开

Non-secret variables declared in the build are automatically turned into environment variables on the build agent.

有意将 not 转换成环境变量,但是您可以添加命令行或脚本任务适用于您的平台(Bash,Powershell等),并通过将秘密作为参数传递给脚本来设置环境变量。

Secret variables are intentionally not turned into environment variables, but you can add a Command Line or Script task that's appropriate for your platform (Bash, Powershell, whatever) and set an environment variable by passing your secret in as a parameter to the script.

这篇关于Azure DevOps构建中的秘密(dotnet核心)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆