TFS 构建定义秘密变量
TFS Build Definition Secret Variables
我的构建定义中有几个秘密变量,我将它们传递给构建步骤参数 属性 中的 powershell 函数,但是它们以 ********* 的形式发送而不是被解密。
我传递给 powershell 脚本调用的参数如下,在构建定义中将 $(accesskey) 和 $(secretkey) 设置为秘密:
-source "$(CodeDeploySource)" -destination "$(CodeDeployDestination)" -Description "$(Description)" -Location "$(Location)" -ApplicationName "$(ApplicationName)" -DeploymentGroup "$(DeploymentGroup)" -DeploymentConfig "$(DeploymentConfig)" -ak "$(accesskey)" -sk "$(secretkey)" -region "$(region)"
我的 powershell 脚本的参数部分是:
param(
[string]$source,
[string]$destination,
[string]$Description,
[string]$Location,
[string]$ApplicationName,
[string]$DeploymentGroup,
[string]$DeploymentConfig,
[string]$ak,
[string]$sk,
[string]$region
)
是否必须在 TFS 中启用配置才能在构建过程中解密秘密变量?
您不需要做任何配置来解密秘密变量。我已经重现了您的问题,并在构建日志中发现,它显示为 *****。实际上,在Official document中提到:
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 脚本中获取并可以成功使用。只是不能输出,因为它是一个秘密变量。
我的构建定义中有几个秘密变量,我将它们传递给构建步骤参数 属性 中的 powershell 函数,但是它们以 ********* 的形式发送而不是被解密。
我传递给 powershell 脚本调用的参数如下,在构建定义中将 $(accesskey) 和 $(secretkey) 设置为秘密:
-source "$(CodeDeploySource)" -destination "$(CodeDeployDestination)" -Description "$(Description)" -Location "$(Location)" -ApplicationName "$(ApplicationName)" -DeploymentGroup "$(DeploymentGroup)" -DeploymentConfig "$(DeploymentConfig)" -ak "$(accesskey)" -sk "$(secretkey)" -region "$(region)"
我的 powershell 脚本的参数部分是:
param(
[string]$source,
[string]$destination,
[string]$Description,
[string]$Location,
[string]$ApplicationName,
[string]$DeploymentGroup,
[string]$DeploymentConfig,
[string]$ak,
[string]$sk,
[string]$region
)
是否必须在 TFS 中启用配置才能在构建过程中解密秘密变量?
您不需要做任何配置来解密秘密变量。我已经重现了您的问题,并在构建日志中发现,它显示为 *****。实际上,在Official document中提到:
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 脚本中获取并可以成功使用。只是不能输出,因为它是一个秘密变量。