Thursday, April 9, 2015

Jenkins and Gradle Behind a Proxy

Getting Jenkins CI to build using Gradle behine a proxy do the following:
1. Specify proxy settings in you gradle.properties file in your project:
# for http
systemProp.http.proxyPort=80
systemProp.http.nonProxyHosts=*.cat.com|localhost
systemProp.http.proxyHost=proxy.ap.cat.com

# for https
systemProp.https.proxyHost=proxy.ap.cat.com
systemProp.https.proxyPort=80
systemProp.https.nonProxyHosts=*.cat.com|localhost

2. Copy these settings to (create if necessary) a gradle.properties file in your USER_HOME/.gradle directory
3. In Jenkins navigate to Manage Jenkins > Configure System. Under Global properties check Environment variables and fill in the following for name and value:
name: GRADLE_OPTS
value: -Dgradle.user.home=/home/tomcat/.gradle -Dhttp.proxyHost=[proxy] -Dhttp.proxyPort=[proxy_port]

Where [proxy] is the proxy url and [proxy_port] is the port for that proxy. Add https options if required.