I have a Jenkins job that uses a Jenkinsfile and groovy script to do a build.
During the testing/scanning phase I would like to send all traffic through a proxy, specifically right before the groovy script does sh "npm run test"
.
Is there a way to specify a proxy url and port right before I run the tests so all traffic from that job goes through it?
According to the documentation you can specify HTTP_PROXY
environment variable. In Jenkins scripted pipeline you can do it this way
withEnv(['HTTP_PROXY=http://proxyAddress:port']) {
sh "npm run test"
}
If you use declarative pipeline you need environment { }
block
environment {
HTTP_PROXY = 'http://proxyAddress:port'
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With