Gradle behind proxy with no Authentication - gradle

I am running gradle (version 2.5) behind a proxy server which does not require authentication. I have set the following in gradle.properties
systemProp.http.proxyHost=rilproxy.in.ril.com
systemProp.http.proxyPort=8080
However I am getting the following exception which complains that proxy server requires authentication. Does gradle expect some dummy value in case there is no proxyUser and proxyPassword. I have confirmed with dont have any authentication credentials for proxy server and this is working fine if I set the same for Ivy build.
Parallel execution with configuration on demand is an incubating feature.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'liferay-plugins-sdk-6.2'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve commons-codec:commons-codec:1.9.
Required by:
:liferay-plugins-sdk-6.2:unspecified
> Could not resolve commons-codec:commons-codec:1.9.
> Could not get resource 'http://cdn.repository.liferay.com/nexus/content/groups/public/com
mons-codec/commons-codec/1.9/commons-codec-1.9.pom'.
> Could not GET 'http://cdn.repository.liferay.com/nexus/content/groups/public/commons-c
odec/commons-codec/1.9/commons-codec-1.9.pom'. Received status code 407 from server: Proxy Authentic
ation Required ( Forefront TMG requires authorization to fulfill the request. Access to the Web Prox
y filter is denied. )

Related

503 from server: Service Unavailable: Back-end server is at capacity

I'm trying to build a jib based container with gradle.
I'm getting a 503 error when it tries to GET an xml file from jfrog.org.
+ eval set -- '"-Xmx64m"' '"-Xms64m"' '"-Xdock:name=Gradle"' '"-Xdock:icon=/Users/username/VSCode/globality-karate-testing/media/gradle.icns"' '"-Dorg.gradle.appname=gradlew"' -classpath '"/Users/username/VSCode/globality-karate-testing/gradle/wrapper/gradle-wrapper.jar"' org.gradle.wrapper.GradleWrapperMain ''\''jibDockerBuild'\'' \
'
++ set -- -Xmx64m -Xms64m -Xdock:name=Gradle -Xdock:icon=/Users/username/VSCode/globality-karate-testing/media/gradle.icns -Dorg.gradle.appname=gradlew -classpath /Users/username/VSCode/globality-karate-testing/gradle/wrapper/gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain jibDockerBuild
+ exec /Users/username/.sdkman/candidates/java/current/bin/java -Xmx64m -Xms64m -Xdock:name=Gradle -Xdock:icon=/Users/username/VSCode/globality-karate-testing/media/gradle.icns -Dorg.gradle.appname=gradlew -classpath /Users/username/VSCode/globality-karate-testing/gradle/wrapper/gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain jibDockerBuild
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'karate-base'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not resolve org.jfrog.buildinfo:build-info-extractor-gradle:4.+.
Required by:
project :
> Failed to list versions for org.jfrog.buildinfo:build-info-extractor-gradle.
> Unable to load Maven meta-data from https://repo.jfrog.org/artifactory/gradle/org/jfrog/buildinfo/build-info-extractor-gradle/maven-metadata.xml.
> Could not get resource 'https://repo.jfrog.org/artifactory/gradle/org/jfrog/buildinfo/build-info-extractor-gradle/maven-metadata.xml'.
> Could not GET 'https://repo.jfrog.org/artifactory/gradle/org/jfrog/buildinfo/build-info-extractor-gradle/maven-metadata.xml'.
Received status code 503 from server: Service Unavailable: Back-end server is at capacity
This appears to be a problem with the jfrog.org server.
It only seems to happen if this is the first time someone has built the project.
Another engineer was able to replicate my error, who had not built this prior.
An engineer who had built the project earlier does not have problems. Seems to be an initialization file.
Heard back from Jfrog support.
The repo https://repo.jfrog.org/artifactory/ has been deprecated.
Replace it with: https://repo1.maven.org/maven2

Could not determine artifacts for org.springframework.boot:spring-boot-starter-parent:

I'm getting some errors :
Could not resolve all dependencies ...
> Could not determine artifacts for org.springframework.boot:spring-boot-starter-parent:1.2.1.RELEASE
> Could not get resource 'https://repo.spring.io/plugins-release/org/springframework/boot/spring-boot-starter-parent/1.2.1.RELEASE/spring-boot-starter-parent-1.2.1.RELEASE.jar'.
> Could not HEAD 'https://repo.spring.io/plugins-release/org/springframework/boot/spring-boot-starter-parent/1.2.1.RELEASE/spring-boot-starter-parent-1.2.1.RELEASE.jar'. Received status code 401 from server: Unauthorized
It requires username and password (I typed the url in the browser)
Update:
Could not resolve all artifacts for configuration ':gisett-backend:classpath'.
Could not find io.spring.gradle:propdeps-plugin:0.0.9.RELEASE.
Searched in the following locations:
- https://jcenter.bintray.com/io/spring/gradle/propdeps-plugin/0.0.9.RELEASE/propdeps-plugin-0.0.9.RELEASE.pom
- https://repo.maven.apache.org/maven2/io/spring/gradle/propdeps-plugin/0.0.9.RELEASE/propdeps-plugin-0.0.9.RELEASE.pom
- https://plugins.gradle.org/m2/io/spring/gradle/propdeps-plugin/0.0.9.RELEASE/propdeps-plugin-0.0.9.RELEASE.pom
How can I fix it? Thanks

Gradle on VirtualBox Ubuntu Host windows 10 behind internet proxy, getting rg.apache.http.ssl.SSLInitializationException: Windows-ROOT not found

I am using gradle on ubuntu (vBox on windows 10). Behind internet proxy. Getting following error.
What went wrong:
A problem occurred configuring project ':master-service'.
Could not resolve all artifacts for configuration ':master-service:classpath'.
Could not download spotbugs-gradle-plugin.jar (gradle.plugin.com.github.spotbugs:spotbugs-gradle-plugin:2.0.0)
> Could not get resource 'https://plugins.gradle.org/m2/gradle/plugin/com/github/spotbugs/spotbugs-gradle-plugin/2.0.0/spotbugs-gradle-plugin-2.0.0.jar'.
> org.apache.http.ssl.SSLInitializationException: Windows-ROOT not found
Could not download spring-boot-gradle-plugin.jar (org.springframework.boot:spring-boot-gradle-plugin:2.2.2.RELEASE)
> Could not get resource 'https://plugins.gradle.org/m2/org/springframework/boot/spring-boot-gradle-plugin/2.2.2.RELEASE/spring-boot-gradle-plugin-2.2.2.RELEASE.jar'.
> org.apache.http.ssl.SSLInitializationException: Windows-ROOT not found
Could not download spring-boot-loader-tools.jar (org.springframework.boot:spring-boot-loader-tools:2.2.2.RELEASE)
> Could not get resource 'https://plugins.gradle.org/m2/org/springframework/boot/spring-boot-loader-tools/2.2.2.RELEASE/spring-boot-loader-tools-2.2.2.RELEASE.jar'.
> org.apache.http.ssl.SSLInitializationException: Windows-ROOT not found
Could not download dependency-management-plugin.jar (io.spring.gradle:dependency-management-plugin:1.0.8.RELEASE)
> Could not get resource 'https://plugins.gradle.org/m2/io/spring/gradle/dependency-management-plugin/1.0.8.RELEASE/dependency-management-plugin-1.0.8.RELEASE.jar'.
> org.apache.http.ssl.SSLInitializationException: Windows-ROOT not found
Could not download commons-compress.jar (org.apache.commons:commons-compress:1.19)
> Could not get resource 'https://plugins.gradle.org/m2/org/apache/commons/commons-compress/1.19/commons-compress-1.19.jar'.
> org.apache.http.ssl.SSLInitializationException: Windows-ROOT not found
Could not download spring-core.jar (org.springframework:spring-core:5.2.2.RELEASE)
> Could not get resource 'https://plugins.gradle.org/m2/org/springframework/spring-core/5.2.2.RELEASE/spring-core-5.2.2.RELEASE.jar'.
> org.apache.http.ssl.SSLInitializationException: Windows-ROOT not found
Could not download spring-jcl.jar (org.springframework:spring-jcl:5.2.2.RELEASE)
> Could not get resource 'https://plugins.gradle.org/m2/org/springframework/spring-jcl/5.2.2.RELEASE/spring-jcl-5.2.2.RELEASE.jar'.
> org.apache.http.ssl.SSLInitializationException: Windows-ROOT not found
I am assuming you are behind a company firewall of some sort. Some things you can try:
Configure Gradle's HTTPS Proxy: https://docs.gradle.org/current/userguide/build_environment.html#sec:accessing_the_web_via_a_proxy
If your company has an internal Maven repository/mirrors Maven Central internally, then you should use that repository instead of the public/internet Gradle one. https://docs.gradle.org/current/userguide/plugins.html#sec:custom_plugin_repositories
Make sure your local JDK installation has your company's root SSL certificate, if one exists. See this answer.

Authenticate sonar-runner via basic auth

Our sonarqube server is behind http basic authentication and local runner fails with 401 error. Is it somehow possible to provide credentials to it? AOfficial docs shows how to provide sonarqube's internal user...
UPD #1:
sonarqube: v5.3,
sonar-runner: v2.5
Debug log of runner:
INFO: Scanner configuration file: /Users/user/Documents/Projects/Project1/sonar-scanner-2.5/conf/sonar-runner.properties
INFO: Project configuration file: /Users/user/Documents/Projects/Project1/sonar-project.properties
INFO: SonarQube Scanner 2.5
INFO: Java 1.8.0_45 Oracle Corporation (64-bit)
INFO: Mac OS X 10.11.3 x86_64
INFO: Error stacktraces are turned on.
DEBUG: cache: /Users/user/.sonar/ws_cache/https%3A%2F%2Fexample.com%2Fsonar%2F/global
INFO: User cache: /Users/user/.sonar/cache
DEBUG: Extract sonar-runner-batch in temp...
DEBUG: Get bootstrap index...
DEBUG: Download: https://example.com/sonar/batch_bootstrap/index
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 1.171s
INFO: Final Memory: 5M/245M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
org.sonar.runner.impl.RunnerException: Unable to execute SonarQube
at org.sonar.runner.impl.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:100)
at org.sonar.runner.impl.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:87)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:87)
at org.sonar.runner.impl.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:83)
at org.sonar.runner.api.EmbeddedRunner.doStart(EmbeddedRunner.java:249)
at org.sonar.runner.api.EmbeddedRunner.start(EmbeddedRunner.java:187)
at org.sonar.runner.api.EmbeddedRunner.start(EmbeddedRunner.java:182)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:66)
Caused by: java.lang.IllegalStateException: Fail to download libraries from server
at org.sonar.runner.impl.Jars.downloadFiles(Jars.java:93)
at org.sonar.runner.impl.Jars.download(Jars.java:70)
at org.sonar.runner.impl.JarDownloader.download(JarDownloader.java:40)
at org.sonar.runner.impl.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:91)
... 9 more
Caused by: java.lang.IllegalStateException: Status returned by url [https://example.com/sonar/batch_bootstrap/index] is not valid: [401]
at org.sonar.runner.impl.ServerConnection.callUrl(ServerConnection.java:186)
at org.sonar.runner.impl.ServerConnection.downloadString(ServerConnection.java:121)
at org.sonar.runner.impl.ServerConnection.tryServerFirst(ServerConnection.java:148)
at org.sonar.runner.impl.ServerConnection.download(ServerConnection.java:112)
at org.sonar.runner.impl.Jars.downloadFiles(Jars.java:78)
... 12 more
No it doesn't look like sonar-runner supports proxy authentication. SonarQube has built-in access control so I'm not sure why you'd need proxy authentication on top of that. Maybe you could disable proxy authentication for SonarQube's URL.
The sonar-runner, even if configured with credentials, does not use these to make it's first call to the server. The endpoint is /batch/index. You have to allow public access to that endpoint. For all other urls basic auth is fine.
More details about my working setup in my answer here: https://stackoverflow.com/a/60132667/1838233
I've tried that setup with the runner and a sonar-project.properties file containing:
sonar.host.url=https://myserver/sonar/
sonar.login=${env.SONARUSER}
sonar.password=${env.SONARPWD}
and could access Sonar behind Apache basic auth that way.
I have been looking for this too and failed to find any options to allow this. One use case I can think of for needing this is you have the sonar client running on the far end of a GCP IAP away from the sonar server. You'd need to have the client pass through the initial proxy to get to the sonar server. Even if the sonar server supports this auth natively you need some way for the client to pass an auth header.
This is for scenarios where you either don't trust sonar or you don't trust the deployment of sonar by some novice, but you do trust a zero-trust protected proxy by gcp's platform

Gradle - unable to set distributionUrl that requires credentials

I am trying to setup Gradle with my Artifactory as the distributionUrl.
When I run gradlew I receive the following exception:
Exception in thread "main" java.lang.RuntimeException: java.io.IOException: Server returned HTTP response code: 401 for URL: ..
I tried to add username:password# to the URL but it did not work.
Any ideas?
Use the username and password properties of the repository closure as explained in the documentation.

Resources