TFS 构建定义秘密变量 [英] TFS Build Definition Secret Variables

查看:27
本文介绍了TFS 构建定义秘密变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的构建定义中有几个秘密变量,我将它们传递给构建步骤的参数属性中的 powershell 函数,但是它们作为 ******** 发送,而不是被解密.

I have several secret variables in my build definition that I'm passing to a powershell function in the argument property for the build step however they are getting sent in as ******** instead of being decrypted.

我传递给 powershell 脚本调用的参数如下,在构建定义中将 $(accesskey) 和 $(secretkey) 设置为机密:

The parameters that I'm passing into the call of the powershell script are the following with $(accesskey) and $(secretkey) set as secret in the build definition:

-source "$(CodeDeploySource)" -destination "$(CodeDeployDestination)" -Description "$(Description)" -Location "$(Location)" -ApplicationName "$(ApplicationName)" -DeploymentGroup "$(DeploymentGroup)" -DeploymentConfig "$(DeploymentConfig)" -ak "$(accesskey)" -sk "$(secretkey)" -region "$(region)"

我的 powershell 脚本的参数部分是:

The parameter section of my powershell script is:

param(
[string]$source,
[string]$destination,
[string]$Description,
[string]$Location,
[string]$ApplicationName,
[string]$DeploymentGroup,
[string]$DeploymentConfig,
[string]$ak,
[string]$sk,
[string]$region
)

是否有必须在 TFS 中启用的配置才能在构建过程中解密秘密变量?

Is there a configuration that has to be enabled in TFS in order for it to decrypt the secret variable during the build process?

推荐答案

你不需要做任何配置来解密秘密变量.我已重现您的问题并在构建日志中找到,它显示为 *****.实际上,在官方文档中有提到:

You don't need to do any configuration to decrypt the secret variables. I have reproduced your issue and found in the build log, it shows like *****. Actually, in the Official document it has mentioned that:

没有返回给客户.它们会被自动屏蔽掉构建或发布的任何日志输出.

Not returned back to the client. They are automatically masked out of any log output from the build or release.

未解密为环境变量.所以脚本和程序运行默认情况下,您的构建步骤不会授予访问权限.

Not decrypted into environment variables. So scripts and programs run by your build steps are not given access by default.

所以从构建日志中是看不出来的.但它不会对您的构建产生影响.该值可以在 PowerShell 脚本中获取并且可以成功使用.只是不能输出,因为它是一个秘密变量.

So it can't be seen from the build log. But it won't have effect for your build. The value could be get in the PowerShell script and could be used successfully. It just can't be output because it's a secret variable.

这篇关于TFS 构建定义秘密变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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