I’m trying to use a password in Jenkins credential section, but my password contains a percentage character (%). And then, for some reason, when I use this credential in a pipeline script the Jenkins remove this character and use the password without this. For example, my password is:
I don’t think it is Jenkins that removed the ‘%’ character. I suspect that the command processor on Windows is seeing the ‘%’ as the start of a variable and is removing it.
I created a Freestyle project and enabled “Use secret text(s) or file(s)” then assigned MY_USER_NAME as the username variable and MY_PASSWORD as the password variable, using an intentionally invalid credential with a password with the value ‘50%-of-people-are-half-the-world’.
Using that credential, I had the batch command step write environment variables to a file that uses the name of that password variable.
My batch script was:
echo My password is %MY_PASSWORD%
echo My user name is %MY_USER_NAME%
set > %MY_PASSWORD%
The console output hides the value of the password, but when I look in the Jenkins workspace browser for that job, it shows a file on the file system named “50%-of-people-are-half-the-world”. Jenkins passed the environment variable through to the Windows bat correctly as far as I can see.