0

I'm running AWS Codebuild within a private network, for that I have created the file .gradle/gradle.properties to use a proxy and inside it I have the following values:

systemProp.https.proxyHost=<https-proxy-host>
systemProp.https.proxyPort=<https-port>
systemProp.http.proxyHost=<http-proxy-host>
systemProp.http.proxyPort=<http-port>
systemProp.http.nonProxyHosts=localhost|127.0.0.1

I'm using AWS's Ubuntu standard image version 5.0 for the build, but I keep getting this error when I run ./gradlew clean build:

Downloading https://services.gradle.org/distributions/gradle-6.8.3-bin.zip

Exception in thread "main" javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target.

To be honest I'm not sure if gradle is aware of the file .gradle/gradle.properties or not to get the proxy values, any thoughts?

SlimenTN
  • 3,383
  • 7
  • 31
  • 78
  • Yes , {userName}/.gradle/gradle.properties is where gradle lastly look for a proxy settings . this is where the global config is stored . can you try gradle --version in terminal ? – George Oct 11 '21 at 18:29
  • @George `gradle --version` is 5.6.4 and it doesn't show me the location of the gradle.properties file! – SlimenTN Oct 12 '21 at 08:24

1 Answers1

0

Make sure to check for GRADLE_USER_HOME environment variable .

which if not set , the defaults path is USER_HOME/.gradle)

Worst case Senario , just to make sure its not a proxy issue ,

you can add the gradle.properties to your project , next to build.gradle .

Actullay there is 3 places where you can have gradle.properties:

  1. USER_HOME/.gradle/gradle.properties and this is global for all gradle projects
  2. In project directory , and this is local for this project
  3. A The sub-project directory

once you tried to have the gradle properties in the project and the issue not solved , probably this is a proxy problem .

while your working with gradlew , You can try to go to ,

[project]/gradle/wrapper/gradle-wrapper.properties and add this if not already exist , as well as proxy setting .

distributionUrl=http\://services.gradle.org/distributions/gradle-6.8.3-bin.zip

Just make sure to remove the 's' from https .

while this may not look fine for some users , here, the accepted answer suggested the following

sudo dpkg --purge --force-depends ca-certificates-java
sudo apt-get install ca-certificates-java

and make gradlew clean afterward .

George
  • 2,292
  • 2
  • 10
  • 21
  • I've already tried the second option, I've created a .gradle folder and under I've created the gradle.properties file with the proxy configuration but I get the error above, and I'm sure that the proxy works fine because it's already used in other pipelines! – SlimenTN Oct 12 '21 at 10:06
  • i updated my answer , hope this help . – George Oct 12 '21 at 10:15
  • ok @George I will mark this as resolved because it gave me a hint which is the `GRADLE_USER_HOME` I couldn't find it so I've created it and make it point on .gradle folder that I've created and it worked, I no longer get the error above :) – SlimenTN Oct 12 '21 at 10:16