Gradle doesn't use proxies in jenkins-as-a-code-pipeline
robinerd opened this issue · 0 comments
robinerd commented
The gradlew commands in "Verify JobDSL" stage fails to fetch plugins behind our corporate firewall since it doesn't use the proxy.
I was able to make it work by passing the proxies as -D parameters to gradlew
Here's what I did, feel free to add it or modify it as you like.
stage('Verify JobDSL') {
proxyHTTP = ""
if(env.http_proxy) {
def tokens = env.http_proxy.replace("http://", "").replace("https://", "").split(':')
def host = tokens[0]
def port = tokens[1]
proxyHTTP = "-Dhttp.proxyHost=${host} -Dhttp.proxyPort=${port}"
}
proxyHTTPS = ""
if(env.https_proxy) {
def tokens = env.https_proxy.replace("http://", "").replace("https://", "").split(':')
def host = tokens[0]
def port = tokens[1]
proxyHTTPS = "-Dhttps.proxyHost=${host} -Dhttps.proxyPort=${port}"
}
sh "cd jobdsl-gradle && ./gradlew ${proxyHTTP} ${proxyHTTPS} buildXml"
sh "cd jobdsl-gradle && ./gradlew ${proxyHTTP} ${proxyHTTPS} test"
}