I need web access from Gradle through a proxy server to use the Gradle/Artifactory integration for Jenkins. To reduce possible causes for issues, I manually add the Artifactory plugin in build.gradle and run it from command line:
apply {
apply from: "http://gradle.artifactoryonline.com/gradle/plugins/org/jfrog/buildinfo/build-info-extractor-gradle/1.0.1/artifactoryplugin-1.0.1.gradle"
}
Following this description I specified the following in .gradle/gradle.properties in my home directory:
systemProp.http.proxyHost=hostname
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=de\\username
systemProp.http.proxyPassword=xxx
With the above proxy configuration (that is otherwise known to work), it fails:
11:33:17.699 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.io.IOException: Server returned HTTP response code: 407 for URL: http://gradle.artifactoryonline.com/gradle/plugins/org/jfrog/buildinfo/build-info-extractor-gradle/1.0.1/artifactoryplugin-1.0.1.gradle
I have two proxy servers to choose from, and one always responds with 407
(Proxy authentication required), the other with 502
(Bad gateway), so obviously, the proxyHost and proxyPort options are used.
As the user name (based on an Active Directory user) contains a backslash, I tried both \\
and \
, but neither worked. The user specified is different from the user that is logged in to the machine and Active Directory. This user's credentials aren't valid for the proxy, so I need to be able to specify a different user.
Setting the same options in Jenkins' or Artifactory's GUI worked.
In my
build.gradle
I have the following task, which uses the usual linux proxy settings,HTTP_PROXY
andHTTPS_PROXY
, from the shell env:Try the following:
gradle -Dhttp.proxyHost=yourProxy -Dhttp.proxyPort=yourPort -Dhttp.proxyUser=usernameProxy -Dhttp.proxyPassword=yourPassoword
For me, works adding this configuration in the gradle.properties file of the project, where the build.gradle file is:
Where : proxyUrl is the url of the proxy server (http://.....)
proxyPort is the port (usually 8080)
USER is my domain user
PASSWORD, my password
In this case, the proxy for http and https is the same
Create a file called
gradle.properties
inside the project folder where thebuild.gradle
file is present. Add the following entryIf you are using DNS for proxy then add it like
systemProp.https.proxyHost=www.proxysite.com
For IP just specify the IP with out
http://
orhttps://
Check gradle official doc for more details and setting up proxy at global level
This is my gradle.properties, please note those HTTPS portion
Based on SourceSimian's response; this worked on Windows domain user accounts. Note that the Username does not have domain included,