Forum Discussion

bhuvanesh1208's avatar
bhuvanesh1208
Copper Contributor
Sep 19, 2022

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

  • sprice092's avatar
    sprice092
    Copper 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. eg

    az pipelines variable-group variable update --group-id $variableGroupId --name $variableName --secret true --project $azureDevOpsProject --org $azureDevOpsOrganisationUrl --value '"ValueWithSpecialChars~^>*@"'




  • bhuvanesh1208 

    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 }}' | base64

    2. 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

    • praveenambati's avatar
      praveenambati
      Copper 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. 

       

Resources