Gradle Proxy Configuration for Web Access
Gradle integration with Artifactory in Jenkins requires web access via a proxy server. Configuring this proxy connection can be challenging, especially when using a backslash in the proxy username or when multiple proxy servers are present.
To specify proxy settings for Gradle, create a .gradle/gradle.properties file in your home directory and include the following properties:
systemProp.http.proxyHost = hostname systemProp.http.proxyPort = 8080 systemProp.http.proxyUser = de\username systemProp.http.proxyPassword = xxx
However, this configuration may lead to HTTP 407 errors. To overcome these issues, use the following refinement based on Daniel's response:
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"
These properties can also be added to the gradle-wrapper.properties file. Alternatively, setting these options in Jenkins' or Artifactory's GUI should also work.
The above is the detailed content of How to Configure Gradle Proxy Settings for Web Access?. For more information, please follow other related articles on the PHP Chinese website!