TFS Build Definition Secret Variables

孤街醉人 提交于 2019-12-25 07:41:33

问题


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.

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)"

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
)

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


回答1:


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.

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.



来源:https://stackoverflow.com/questions/43713540/tfs-build-definition-secret-variables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!