Used :
withEnv([‘http_proxy=https://${PROXY_CREDENTIALS}@proxy-endpoint.com:3128'])
{
Note the single quotes, this needs to be double-quoted for the replacement
to happen.
Björn
kelvSYC schrieb am Montag, 8. März 2021 um 22:29:00 UTC+1:
> Suppose I have a username and password credential that I use with a
> withCredentials step, and I wish to use it to construct a URL for use with
> the http_proxy environment variable. Currently I have this:
>
> withCredentials([usernameColonPassword(credentialsId:’proxy-credentials’,
> variable: ‘PROXY_CREDENTIALS')]) {
> def url = “https://${env.PROXY_CREDENTIALS}@proxy-endpoint.com:3128”
> withEnv([“http_proxy=${url}”]) {
> // Do something
> }
> }
>
> This gets flagged as unsafe by Jenkins (likely rightly), so I’m wondering
> what safe way there is to do the same thing.
>
> Something like the following doesn’t work for me:
>
> withCredentials([usernameColonPassword(credentialsId:’proxy-credentials’,
> variable: ‘PROXY_CREDENTIALS')]) {
> withEnv([‘http_proxy=https://${PROXY_CREDENTIALS}@proxy-endpoint.com:3128'])
> {
> // Do something
> }
> }
>
> All it does is that the http_proxy variable is populated with the literal
> ${PROXY_CREDENTIALS} string instead of the value therein.
>
> Any assistance in this would be appreciated.
>
>
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/2e09f1ff-d7d7-4ba3-a84d-2455dfe1d5acn%40googlegroups.com.