I am currently facing an issue, where I have to use parameters and credentials in the same shell string, which is causing me a lot of trouble.
When handling passwords in Jenkins the documentation emphasizes the use of single quotes to avoid the interpolation of sensitive variables:
Single quote example:
However, using single quotes will result in my parameters not being interpolated as showed in the below picture:
Thus, I can't find a solution which allows my to have both, and as I see it, this leaves me with one of the following options:
Do someone know if it is possible to have both in the same string or know some sort of workaround?
You can use double quotes, but escape the $
for the secret variables like this:
sh("curl -u \$USERNAME:\$PASSWORD ${url}")
You can also use single quotes:
sh('curl -u $USERNAME:$PASSWORD ' + url)
You can use it with withCredentials()
.