Docker maven and jenkins, mvn install failed requesting junit:junit:jar:3.x

I have a maven 3.2.5 docker image and a jenkins image built from the maven image.

Maven image Dockerfile:

  • How to scale out VMs in Azure Container Service Docker?
  • All Docker container statuses?
  • How to see the logs of running application inside docker container?
  • Garbage collecting Docker registry using S3 is very slow
  • Docker memory overhead
  • determine OS distribution of a docker image
  • from dockerfile/java:oracle-java7
    
    
    ENV MAVEN_VERSION 3.2.5
    RUN curl -sSL http://mirror.bit.edu.cn/apache/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz | tar xzf - -C /usr/share \
    && mv /usr/share/apache-maven-$MAVEN_VERSION /usr/share/maven \
    && ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
    #ADD settings.xml /usr/share/maven/conf/
    ENV MAVEN_HOME /usr/share/maven
    CMD ["mvn"]
    

    Jenkins Dockerfile:

    from javcly/fongwell:maven
    RUN mkdir -p /data/jenkins && mkdir -p /var/lib/jenkins
    RUN touch /data/jenkins/jenkins.log
    
    
    ADD jenkins.war /var/lib/jenkins/
    VOLUME /data/jenkins
    ENV JENKINS_HOME /data/jenkins
    
    EXPOSE 8080
    
    CMD ["java","-jar","/var/lib/jenkins/jenkins.war","--webroot=/data/jenkins","--logfile=/data/jenkins/jenkins.log"]
    

    then I start the jenkins image with the command:

    docker run -d -v /data/docker/jenkins:/data/jenkins -v /usr/share/maven-repo:/root/.m2/repository  --name jenkins -p 27099:8080 --add-host git.mydomain.com:192.168.0.119  docker:jenkins
    

    as above, /root/.m2/repository on the container is mounted to /usr/share/maven-repo on the host machine

    now I set up my project on Jenkins and pull down source code from Git, run

    mvn clean install -X
    

    it gives me this error

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install (default-install) on project infrastrucure: Execution default-install of goal org.apache.maven.plugins:maven-install-plugin:2.4:install failed: Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved: Could not find artifact junit:junit:jar:3.x in central (https://repo.maven.apache.org/maven2) -> [Help 1]
    org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install (default-install) on project infrastrucure: Execution default-install of goal org.apache.maven.plugins:maven-install-plugin:2.4:install failed: Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved: Could not find artifact junit:junit:jar:3.x in central (https://repo.maven.apache.org/maven2)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
    Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-install of goal org.apache.maven.plugins:maven-install-plugin:2.4:install failed: Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved: Could not find artifact junit:junit:jar:3.x in central (https://repo.maven.apache.org/maven2)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:104)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        ... 19 more
    Caused by: org.apache.maven.plugin.PluginResolutionException: Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved: Could not find artifact junit:junit:jar:3.x in central (https://repo.maven.apache.org/maven2)
        at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.java:208)
        at org.apache.maven.plugin.internal.DefaultMavenPluginManager.createPluginRealm(DefaultMavenPluginManager.java:361)
        at org.apache.maven.plugin.internal.DefaultMavenPluginManager.setupPluginRealm(DefaultMavenPluginManager.java:329)
        at org.apache.maven.plugin.DefaultBuildPluginManager.getPluginRealm(DefaultBuildPluginManager.java:229)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:100)
        ... 20 more
    Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact junit:junit:jar:3.x in central (https://repo.maven.apache.org/maven2)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
        at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:367)
        at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.java:200)
        ... 24 more
    Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact junit:junit:jar:3.x in central (https://repo.maven.apache.org/maven2)
        at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:39)
        at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:355)
        at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)
    

    If I build the same project on the host machine directly, it is SUCCESSFUL!

    Running mvn dependency:tree -Dverbose -Dincludes=junit gave me the same error:

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.8:tree (default-cli) on project infrastrucure: Execution default-cli of goal org.apache.maven.plugins:maven-dependency-plugin:2.8:tree failed: Plugin org.apache.maven.plugins:maven-dependency-plugin:2.8 or one of its dependencies could not be resolved: Could not find artifact junit:junit:jar:3.x in nexus-osc (http://maven.oschina.net/content/groups/public/) -> [Help 1]
    [ERROR] 
    

    What is wrong here?

  • Kubernetes Service External IP not being assigned
  • binding of ports not working in docker
  • Docker - duplicate mssql database
  • How to include files outside of Docker's build context?
  • Undertsanding docker build
  • Invalid ELF header xgboost (using a pkl in a Docker container)
  • One Solution collect form web for “Docker maven and jenkins, mvn install failed requesting junit:junit:jar:3.x”

    3.x isn’t a version as such, so there is nothing to find. You need to replace the x with a concrete number.

    See here for a list of versions: http://mvnrepository.com/artifact/junit/junit

    An example for your pom would be:

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.7</version>
    </dependency>
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.