Open javydreamercsw opened 1 year ago
It seems like it cannot access to the internet
, especially to the https://repo.maven.apache.org/maven2
.
We are able to verify by executing the following command at the host machine.
docker run -it --rm maven:3.9.1-eclipse-temurin-11 \
bash -c \
'wget https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/3.3.0/maven-resources-plugin-3.3.0.pom \
-O /tmp/pom.xml \
&& ls -la /tmp/pom.xml'
Moreover, If I'm not wrong, you're using Jekins
. We may add something like pre-build step
to ensure that connectivity as well.
# Pre-Build Step
- wget https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/3.3.0/maven-resources-plugin-3.3.0.pom -O /tmp/pom.xml
- ls -la /tmp/pom.xml
Furthermore If the internet connection requires the Proxy
, please visit the Apache Maven: Configuring a proxy for setting up the ~/.m2/settings.xml
as the following example.
<settings>
.
.
<proxies>
<proxy>
<id>example-proxy</id>
<active>true</active>
<protocol>http</protocol>
<host>proxy.example.com</host>
<port>8080</port>
<username>proxyuser</username>
<password>somepassword</password>
<nonProxyHosts>www.google.com|*.example.com</nonProxyHosts>
</proxy>
</proxies>
.
.
</settings>
Regarding to the following, Apart from modifying the settings.xml
, we're also able to pass the proxy configuration as a command line argument
, too.
I disagree, something else is very wrong here:
This means that Maven cannot "speak" HTTP at all, as there are NO connectors for HTTP. Maven 3.9.x by default includes two connectors for HTTP (old resolver-transport-wagon and new resolver-transport-http).
This looks more like broken/incomplete deployment, or something else that made Maven not have connectors available.
Here is the list jar files inside the lib directory. I'm not sure if this may be any clue or not.
docker run -it --rm maven:3.9.1-eclipse-temurin-11 bash
# Inside the bash for this container
mvn -v
# Apache Maven 3.9.1 (2e178502fcdbffc201671fb2537d0cb4b4cc58f8)
# Maven home: /usr/share/maven
# Java version: 11.0.18, vendor: Eclipse Adoptium, runtime: /opt/java/openjdk
# Default locale: en_US, platform encoding: UTF-8
# OS name: "linux", version: "3.10.0-1062.el7.x86_64", arch: "amd64", family: "unix"
ls -la /usr/share/maven/lib | grep transport
# -rw-r--r--. 1 root root 16230 Mar 15 09:39 maven-resolver-transport-file-1.9.7.jar
# -rw-r--r--. 1 root root 50468 Mar 15 09:39 maven-resolver-transport-http-1.9.7.jar
# -rw-r--r--. 1 root root 32439 Mar 15 09:39 maven-resolver-transport-wagon-1.9.7.jar
ls -la /usr/share/maven/lib | grep wagon
# -rw-r--r--. 1 root root 32439 Mar 15 09:39 maven-resolver-transport-wagon-1.9.7.jar
# -rw-r--r--. 1 root root 11350 Mar 15 09:39 wagon-file-3.5.3.jar
# -rw-r--r--. 1 root root 9405 Mar 15 09:39 wagon-http-3.5.3.jar
# -rw-r--r--. 1 root root 40832 Mar 15 09:39 wagon-http-shared-3.5.3.jar
# -rw-r--r--. 1 root root 55101 Mar 15 09:39 wagon-provider-api-3.5.3.jar
I guess that image is ok, but am more interested in reporter's (same as @charleech) output, as nobody else reported such a problem, while 3.9.1 image is out for quite while. Inability of maven to download anything (due lack of connectors) would most probably trigger a swarm of issues.... :smile:
Do you have an example project where it is broken? There are tests in this repo and they are passing
Added the connectivity check to my pipeline and seems to have worked fine:
[Pipeline] sh
+ wget https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/3.3.0/maven-resources-plugin-3.3.0.pom -O /tmp/pom.xml
--2023-04-21 13:04:47-- https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/3.3.0/maven-resources-plugin-3.3.0.pom
Resolving repo.maven.apache.org (repo.maven.apache.org)... 151.101.144.215
Connecting to repo.maven.apache.org (repo.maven.apache.org)|151.101.144.215|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8499 (8.3K) [text/xml]
Saving to: ‘/tmp/pom.xml’
0K ........ 100% 76.9M=0s
2023-04-21 13:04:47 (76.9 MB/s) - ‘/tmp/pom.xml’ saved [8499/8499]
[Pipeline] sh
+ ls -la /tmp/pom.xml
-rw-r--r-- 1 root root 8499 Jul 23 2022 /tmp/pom.xml
I could try to make the project available if needed or a version of it.
Any updates?
Do you have an example project where it is broken? There are tests in this repo and they are passing
Project is private. Nothing I can share. I could try to create a version to share
[debug] Running command mvn install -DskipTests=true -X in /home/jenkins/agent/workspace/_TestNG_Maven_Mojo_release_1.0.0/target/project-to-test/TestChangesMojoChangesInParentClassTest1682024612217
Apache Maven 3.9.1 (2e178502fcdbffc201671fb2537d0cb4b4cc58f8)
Maven home:
<unknown Maven home>
<------------------------------------------- Here is the suspected.Java version: 11.0.18, vendor: Eclipse Adoptium, runtime: /opt/java/openjdk
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.15.0-1017-aws", arch: "amd64", family: "unix"
It looks like there will be something wrong with the ${maven.home}
so that it prints as Maven home: <unknown Maven home>
.
Regarding my previous comment (https://github.com/carlossg/docker-maven/issues/365#issuecomment-1517610176) in my environment it prints as Maven home: /usr/share/maven
As far as I understand, if the Maven is not able to locate the ${maven.home}
it also cannot load the required jar files at ${maven.home}/lib
as well.
This is the YAML file I'm using for this in case it helps:
"""
apiVersion: v1
kind: Pod
metadata:
labels:
jenkins: runners
spec:
containers:
- command:
- cat
image: maven:3.9.1-eclipse-temurin-11
imagePullPolicy: Always
name: maven
tty: true
volumeMounts:
- mountPath: /root/.m2/repository
name: maven-repo
volumes:
- hostPath:
path: /root/maven_shared_repo/.m2
type: DirectoryOrCreate
name: maven-repo"""
Running MavenCLI throws this error on maven:3.9.1-eclipse-temurin-11: