Gradle Proxy Configuration: Troubleshooting Proxy Authentication and User Credentials
When integrating Jenkins with Artifactory using the Gradle/Artifactory plugin, connecting to the proxy server through Gradle may encounter errors. One common issue arises when the proxy requires authentication, such as proxy servers that return HTTP 407 (Proxy authentication required).
To resolve this, the proxy configuration must be explicitly set in Gradle. However, the given configuration in .gradle/gradle.properties uses the systemProp property prefix, which is intended for system properties, not Gradle-specific properties.
Instead, use the following syntax within a .gradle or gradle.properties file:
gradle.proxyHost = "hostname" gradle.proxyPort = 8080 gradle.proxyUser = "username" gradle.proxyPassword = "password"
Additionally, ensure that the username specified contains a backslash character (), not a forward slash (/). If credentials for a separate user are required, specify those credentials in the configuration.
HTTP and HTTPS Proxy Configuration
Beyond HTTP proxy configuration, situations may arise where either HTTP or HTTPS protocols require separate proxies or if both protocols need to be configured. The following syntax demonstrates these scenarios:
HTTP Only Proxy configuration
gradlew -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=3128 "-Dhttp.nonProxyHosts=*.nonproxyrepos.com|localhost"
HTTPS Only Proxy configuration
gradlew -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=3129 "-Dhttp.nonProxyHosts=*.nonproxyrepos.com|localhost"
Both HTTP and HTTPS Proxy configuration
gradlew -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=3128 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=3129 "-Dhttp.nonProxyHosts=*.nonproxyrepos.com|localhost"
Proxy configuration with user and password
gradlew -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=3128 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=3129 -Dhttps.proxyUser=user -Dhttps.proxyPassword=pass -Dhttp.proxyUser=user -Dhttp.proxyPassword=pass -Dhttp.nonProxyHosts=host1.com|host2.com
Remember to specify the appropriate URLs in the -Dhttp.nonProxyHosts parameter for the hosts that should not be routed through the proxy.
By following these guidelines, you should be able to successfully configure proxy access within Gradle and leverage the Gradle/Artifactory integration in Jenkins.
The above is the detailed content of How to Configure Proxy Authentication and User Credentials in Gradle for Jenkins Integration with Artifactory?. For more information, please follow other related articles on the PHP Chinese website!