-
Notifications
You must be signed in to change notification settings - Fork 3
Description
In teamcity, variables are denoted by an opening and closing percent symbol: %my_var%
If a keyvault secret value contains two percent symbols (e.g., my%keyvault%secretValue), the plugin fails to evaluate the secret value and returns the name of the parameter instead. It seems that the secret value is somehow being interpolated by teamcity as containing a variable name.
Moreover, the variable interpolation seems to happen twice before being returned. Variables can be escaped by being duplicated %%. So I tried setting my secret value as my%%keyvault%%secretValue, but this still failed. When I quadrupled each % symbol, it evaluated correctly. my%%%%keyvault%%%%secretValue evaluates to my desired result of my%keyvault%secretValue.
To reproduce:
-
create a keyvault secret with value of
my%keyvault%secretValue -
add a parameter
myparameterin a teamcity build referencing the keyvault secret.
Value should look like:%keyvault:my-kv/my-secret-name% -
create a teamcity build step with a powershell (or other cli) runner to echo the parameter:
echo '%myparameter%' -
the build log will contain a line showing the parameter name where there should be a mask for the secret value:
[20:58:12] [Step 1/1] %myparameter%
-
change the keyvault secret value to
my%%%%keyvault%%%%secretValue. -
run the build step again. Output should look something like this:
[20:58:12] [Step 1/1] ***********
The mask shows that the secret is being retrieved and evaluated successfully.