Itai Ganot Itai Ganot - 4 days ago 4x
Groovy Question

Groovy: How to include special characters in a variable and glue it with other variables?

I'm trying to build a curl command:

CURL_COMMAND = ${MP_BASE_URL}${REQUEST_URL}&sig=${SIGNATURE}.replaceAll(' ','%20')

When I run the code I get the following error:

unexpected token: & at line: 34, column: 52

The CURL_COMMAND variable should look like that:

But I'm having trouble getting the "&" to be printed as part of the URL.

here are some of my tries:

CURL_COMMAND = "${MP_BASE_URL}${REQUEST_URL}'&sig='${SIGNATURE}.replaceAll(' ','%20')"
CURL_COMMAND = "${MP_BASE_URL}${REQUEST_URL}+'&sig='+${SIGNATURE}.replaceAll(' ','%20')"

Any ideas how can I accomplish my aim?


How about something like this:-

def CURL_COMMAND = "${MP_BASE_URL}${REQUEST_URL}&sig=${SIGNATURE}".replaceAll(' ','%20')