Forum Discussion
Special Characters not accepted in Azure Pipeline variable
Hi,
I'm trying to set password in pipeline variable and use that variable for encoding it in base64 format before uploading to key vault. But when i try to set password with special characters like $,",', \ etc. its not accepting.
FYI I'm trying to implement this via bash script task in Azure DevOps pipeline.
Value provided in pipeline variable: test$123*'>"pl
Any help would be really appreciated.
Regards
Bhuvanesh.S
6 Replies
- sprice092Copper Contributor
Not sure if you're stilling having the issue, but this might help anyone that comes across it. I ran into a similar issue with using the az cli on PowerShell.
To get around it, you can enclose your value in double quotes inside of single quotes. egaz pipelines variable-group variable update --group-id $variableGroupId --name $variableName --secret true --project $azureDevOpsProject --org $azureDevOpsOrganisationUrl --value '"ValueWithSpecialChars~^>*@"' - balasubramanimIron Contributor
Azure DevOps pipeline variables can have issues with special characters like $, ", ', and \ — especially when used in bash scripts.
1. Wrap the variable in single quotes in the script:
echo '${{ variables.mySecret }}' | base642. Escape special characters if setting the value inline:
variables:
mySecret: "test\$123*'>\"pl"3. Use a secure pipeline variable (marked as secret) and pass it safely:
echo "$MY_SECRET" | base64- praveenambatiCopper Contributor
Hi bhuvanesh1208
I have tried with below pipeline code, but no displayed the out as expected.variables:
- group: dev
steps:
- script: echo '${{variables.db_name}}' | base64
displayName: "Print db_name"
output:
expected to print db_name : $*)@*$))($)!_!3242&*)@#_Below is the variable group created for testing.
- muradhaider5Copper Contributor
bhuvanesh1208
try Url encoding the string before use. - bhuvanesh1208Copper Contributor
bhuvanesh1208 This is very critical for me, Can someone throw some light onto this.
- praveenambatiCopper Contributor
Have you figure out the fix ? bhuvanesh1208