Amiga500
Amiga500

Reputation: 6131

Groovy - Problem with character in the password

This is bugging me for a while. In Jenkins I have the correct password. Password looks something like this:

def myPass = 'ZagZS5DMK6$xq26Nx'

Please note the "$" character. Now I want to export that password in to the variable:

--set env.MYSQL_PASSWORD=${mySqlPassword} \

The password looks like this:

ZagZS5DMK6

I was playing around, and I tried using URLencoder, like this:

--set env.MYSQL_PASSWORD=${URLEncoder.encode(mySqlPassword)} \

And the password is broken still.

What can I do to preserve my password with the special characters?

Upvotes: 0

Views: 2124

Answers (1)

Federico klez Culloca
Federico klez Culloca

Reputation: 27119

The string is being interpreted as ZagZS5DMK6 followed by a variable called $xq26Nx, which doesn't exist so it expands to an empty string.

Putting single quotes around the string will avoid the $ being interpreted as the beginning of a variable name and will be interpreted literally, instead.

--set env.MYSQL_PASSWORD='${mySqlPassword}'

Upvotes: 1

Related Questions