Hi, I need to upload jars to a nexus repository from a VM that must go through a proxy server. I can upload jars from a non-proxied machine with this gradle task:
//Upload Jar to Maven Repo (nexus)
uploadArchives {
repositories {
mavenDeployer {
repository(url: nexusRoot + “snapshots/”)
{
authentication(userName: rootProject.nexusUser , password: rootProject.nexusPassword)
}
pom.groupId = rootProject.group
pom.artifactId = project.name
pom.version = rootProject.version + “-SNAPSHOT”
}
}
}
But it fails on the proxied required Jenkins environment with:
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ‘:utils:uploadArchives’.
Could not publish configuration ‘archives’
Failed to retrieve remote metadata :utils:1.0-SNAPSHOT/maven-metadata.xml: Could not transfer metadata :utils:1.0-SNAPSHOT/maven-metadata.xml from/to remote (https://nexus1.ci.whorocks.com/nexus/content/repositories/snapshots/): Connection to https://nexus1.ci.whorocks.com refused
We’ve tried:
-
Supply JVM args/switches, -Dhttps.proxyHost and -Dhttps.proxyPort in the Jenkins gradle task. It’s ignored by MavenDeployer. Other unrelated tasks requiring external connections work.
-
mavenDeployer {
repository(url: nexusRoot + “snapshots/”)
{
proxyHost = System.getProperty(“https.proxyHost”)
proxyPort = System.getProperty(“https.proxyPort”)
println “proxyHost = " + proxyHost + " proxyPort=” + proxyPort
authentication(userName: rootProject.nexusUser, password: rootProject.nexusPassword)
proxy(host: proxyHost, port: Integer.valueOf(proxyPort))
} -
And this:
//Upload Jar to Maven Repo (nexus)
uploadArchives {
repositories {
mavenDeployer {
repository(url: nexusRoot + “snapshots/”) {
authentication(userName: rootProject.nexusUser, password: rootProject.nexusPassword)
releases()
snapshots()
proxy()
}
pom.groupId = rootProject.group
pom.artifactId = project.name
pom.version = rootProject.version + “-SNAPSHOT”
}
}
}
}
All with the same error. We’ve run a netstat on the Jenkins slave and can see the request attempt to go directly to the nexus repo, not the proxy server. Proxy args are ignored.
Any thoughts? Appreciate it.