Closed fjakop closed 5 years ago
Hi @fjakop,
Can you post the result of mvn -U help:effective-settings
at the project root, stripping sensitive info? Also, does it have <username>
and <password>
, and if so, is the password encrypted?
Lastly, can you also try setting the proxy properties on the command line to see if it works? Like mvn -U -Dhttp.proxyHost=...
. Do this for both HTTP and HTTPS (http.xxx
and https.xxx
).
<?xml version="1.0" encoding="Cp1252"?>
<!-- ====================================================================== -->
<!-- -->
<!-- Generated by Maven Help Plugin on 2019-01-14T13:08:34+01:00 -->
<!-- See: http://maven.apache.org/plugins/maven-help-plugin/ -->
<!-- -->
<!-- ====================================================================== -->
<!-- ====================================================================== -->
<!-- -->
<!-- Effective Settings for 'me' on 'computer' -->
<!-- -->
<!-- ====================================================================== -->
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
<localRepository>c:\my\apache-maven-repository</localRepository>
<proxies>
<proxy>
<host>172.x.x.x</host>
<nonProxyHosts>localhost|srv-abc|*.int</nonProxyHosts>
</proxy>
</proxies>
<servers>
<server>
<username>foo</username>
<password>***</password>
<id>nexus-ee</id>
</server>
</servers>
<profiles>
<profile>
<repositories>
<repository>
<snapshots />
<id>snapshots2</id>
<url>http://my-nexus:8081/nexus/content/groups/public-snapshots/</url>
</repository>
<repository>
<id>releases</id>
<url>http://my-nexus:8081/nexus/content/groups/public/</url>
</repository>
<repository>
<id>ee</id>
<url>http://my-nexus:8081/nexus/content/repositories/ee</url>
</repository>
</repositories>
<id>abc</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>abc</activeProfile>
</activeProfiles>
<pluginGroups>
<pluginGroup>org.apache.maven.plugins</pluginGroup>
<pluginGroup>org.codehaus.mojo</pluginGroup>
</pluginGroups>
</settings>
Specifying both -Dhttp.proxy...=
and -Dhttps.proxy...=
seems to work.
@fjakop I think the following will work. You need to specify <protocol>
, and for both HTTP and HTTPS proxying.
<proxies>
<proxy>
<id>for-https-proxying</id> <!-- Make sure you use different IDs -->
<!-- For HTTPS proxying. AFAIK, the Maven doc is wrong about this. -->
<protocol>https</protocol>
<host>172.x.x.x</host>
<nonProxyHosts>localhost|srv-abc|*.int</nonProxyHosts>
</proxy>
<proxy>
<id>for-http-proxying</id>
<protocol>http</protocol> <!-- for HTTP proxying -->
<host>172.x.x.x</host>
<nonProxyHosts>localhost|srv-abc|*.int</nonProxyHosts>
</proxy>
</proxies>
The Maven settings.xml doc suggests the default for an absent protocol is for http
.
I will have to double check, but probably we are getting the default value (http
) for <protocol>
from the Maven API.
However, in this issue (and in most usual cases I think) the https
needs to be defined too.
UPDATED: confirmed. Jib gets http
when not specified. However, users should have a proxy entry for https
too in almost all cases.
@fjakop just in case, add different <id>
values to both. I've seen somewhere that it may work in a weird way when using the same <id>
value.
Yeah, definitely add different <id>
values. I see that if I use the same value, looks like the Maven API ignores the second proxy setting. I've updated the example in https://github.com/GoogleContainerTools/jib/issues/1403#issuecomment-454055859.
@fjakop how exactly did you -Dhttp.proxy...=
and -Dhttps.proxy...=
?
I'm trying to build docker image within a coporate proxy like so:
mvn compile jib:dockerBuild
how can I add those attributes to the command ?
https://docs.oracle.com/javase/8/docs/api/java/net/doc-files/net-properties.html
@SlimenTN like mvn -Dhttp.proxyHost=my.company.proxy.com -Dhttp.proxyPort=... -Dhttps.proxyHost=... compile ...
.
I will have to double check, but probably we are getting the default value (
http
) for<protocol>
from the Maven API.However, in this issue (and in most usual cases I think) the
https
needs to be defined too.UPDATED: confirmed. Jib gets
http
when not specified. However, users should have a proxy entry forhttps
too in almost all cases.
I found this older issue, because I had the same problem as @fjakop . I think the advice/solution to add an https
entry in the settings.xml is misleading.
According to https://maven.apache.org/settings.html#proxies the protocol
is the protocol for connecting to the proxy. It's not the protocol of the target URL.
When I add an additional https
entry in my settings.xml I get problems with connection to https:// URLs, because in my case the proxy is always using an http connection, also for https:// target URLs. The https
entry breaks this.
So I think jib should not ignore a proxy entry with http
protocol for https:// target URLs (from the above that's what I understood is happening, please correct me if it's wrong). Other connections to https:// URLs initiated by Maven are working. So to me it looks like a jib bug. Maybe you could check this again @chanseokoh ?
A workaround which worked for me was setting MAVEN_ARGS
with the -Dhttp.* and -Dhttps.*
properties.
UPDATE: just found #3796 ... better to follow-up there. Sorry for the noise.
Take a look at this:
https://github.com/GoogleContainerTools/jib/pull/1337#issuecomment-447052026
Description of the issue: A
dockerBuild
fails on Windows 10 behind a corporate proxy. The docker registry can not be reached.Expected behavior: The maven build should pull the base image and use the proxy settings in
settings.xml
Steps to reproduce:
~/.m2/settings.xml
src/main/java
** build image withmvn clean compile -Dimage=dockertest:0.0.1 com.google.cloud.tools:jib-maven-plugin:1.0.0-rc1:dockerBuild
Environment:
Windows 10
java -version
docker info
mvn -version
Log output:
Additional Information:
docker pull
,docker push
)