Maven 无法从 Artifactory Repository 下载

标签 maven jenkins artifactory

我正在尝试将我们的 Jenkins 服务器连接到我们的 Artifactory 存储库以进行构建。我在办公地点使用 Jenkins 服务器成功,但我在使用位于公司网络另一部分的 Jenkins 服务器时遇到问题。

我已禁用作业,进入工作区,并尝试直接使用 mvn:

$ mvn clean
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] PROJ Generic Aggregate POM
[INFO] PROJ Generic Module
[INFO] PROJ Generic Features
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building PROJ Generic Aggregate POM 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://repo.vegicorp.net/artifactory/plugins-release/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom

然后它在吐出之前卡住了:

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] PROJ Generic Aggregate POM ........................ FAILURE [2:06.295s]
[INFO] PROJ Generic Module ............................... SKIPPED
[INFO] PROJ Generic Features ............................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:07.160s
[INFO] Finished at: Wed Feb 11 18:16:46 EST 2015
[INFO] Final Memory: 8M/149M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.4.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.4.1: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.4.1 from/to central (http://repo.vegicorp.net/artifactory/plugins-release): Connection to http://repo.vegicorp.net refused: Connection timed out -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
to

但是,如果我尝试通过 curl 获取该 URL,它会毫无问题地下载。与 wget 相同:

$ curl http://repo.vegicorp.net/artifactory/plugins-release/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom
<?xml version='1.0' encoding='UTF-8'?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

因此,我可以通过 wgetcurl 访问该 URL,但 Maven 本身似乎在获取该 URL 时遇到问题。我已经在我的 ~/.m2/settings.xml 中添加了一个 proxy 设置,但这似乎没有任何区别。我们最初将 Maven 存储库设置为从端口 80 重定向到端口 8080,但是从 URL 添加或删除端口号没有任何区别。 settings.xml 来自 Artifactory,它将为您生成。同样的 settings.xml 在我们的办公室工作。

删除 settings.xml 允许一切正常工作,因为它可以从标准 Maven 存储库下载。

我的settings.xml:

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <servers>
    <server>
      <username>dweintraub</username>
      <password>AP8SoMtGnYpACsAwZo5oqUCfSYP</password>
      <id>central</id>
    </server>
    <server>
      <username>dweintraub</username>
      <password>AP8SoMtGnYpACsAwZo5oqUCfSYP</password>
      <id>snapshots</id>
    </server>
  </servers>
  <profiles>
    <profile>
      <repositories>
        <repository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>libs-release</name>
          <url>http://repo.vegicorp.net/artifactory/libs-release</url>
        </repository>
        <repository>
          <snapshots />
          <id>snapshots</id>
          <name>libs-snapshot</name>
          <url>http://repo.vegicorp.net/artifactory/libs-snapshot</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>plugins-release</name>
          <url>http://repo.vegicorp.net/artifactory/plugins-release</url>
        </pluginRepository>
        <pluginRepository>
          <snapshots />
          <id>snapshots</id>
          <name>plugins-snapshot</name>
          <url>http://repo.vegicorp.net/artifactory/plugins-snapshot</url>
        </pluginRepository>
      </pluginRepositories>
      <id>artifactory</id>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>artifactory</activeProfile>
  </activeProfiles>
</settings>

还有一个文件 ~/.m2/repositories/org/apache/maven/plugins/maven-clean-plugins/2.4.1/maven-clean-plugin-2.4.1.pom.lastUpdated 包含以下内容:

#NOTE: This is an internal implementation file, its format can be changed without prior notice.
#Wed Feb 11 18:16:46 EST 2015
da39a3ee5e6b4b0d3255bfef95601890afd80709@proxy.gain.tcprod.local\:3128>2f606e371a64780e100321226a9f68a38c8b7906@default-http\://repo.vegicorp.net/artifactory/plugins-release/.lastUpdated=1423695463870
2f606e371a64780e100321226a9f68a38c8b7906@default-http\://repo.vegicorp.net/artifactory/plugins-release/.lastUpdated=1423696543392
http\://repo.vegicorp.net/artifactory/plugins-release/.error=Could not transfer artifact org.apache.maven.plugins\:maven-clean-plugin\:pom\:2.4.1 from/to central (http\://repo.vegicorp.net/artifactory/plugins-release)\: Connection to http\://repo.vegicorp.net refused
http\://repo.fusesource.com/nexus/content/repositories/releases/.lastUpdated=1423694766347
http\://repo.vegicorp.net/artifactory/plugins-snapshot/.error=Could not transfer artifact org.apache.maven.plugins\:maven-clean-plugin\:pom\:2.4.1 from/to snapshots (http\://repo.vegicorp.net/artifactory/plugins-snapshot)\: Connection to http\://repo.vegicorp.net refused
2f606e371a64780e100321226a9f68a38c8b7906@default-http\://repo.vegicorp.net/artifactory/plugins-snapshot/.lastUpdated=1423696606400
http\://repo.fusesource.com/nexus/content/repositories/releases/.error=
http\://repo.vegicorp.net/artifactory/plugins-release/.error=Could not transfer artifact org.apache.maven.plugins\:maven-clean-plugin\:pom\:2.4.1 from/to central (http\://repo.vegicorp.net/artifactory/plugins-release)\: Failed to transfer file\: http\://repo.vegicorp.net/artifactory/plugins-release/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom. Return code is\: 504 , ReasonPhrase\:Gateway Time-out.

That looks like a proxy settings problem. Can you please add the ouptut of mvn help:effective-settings to the question? Thanks!

我要哭了……

$ mvn help:effective-settings
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] PROJ Generic Aggregate POM
[INFO] PROJ Generic Module
[INFO] PROJ Generic Features
Downloading: http://repo.fusesource.com/nexus/content/repositories/releases/org/apache/maven/plugins/maven-deploy-plugin/2.7/maven-deploy-plugin-2.7.pom
Downloading: http://repo.vegicorp.net/artifactory/plugins-release/org/apache/maven/plugins/maven-deploy-plugin/2.7/maven-deploy-plugin-2.7.pom

然后它卡住并显示:

[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-deploy-plugin:2.7: Plugin org.apache.maven.plugins:maven-deploy-plugin:2.7 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-deploy-plugin:jar:2.7

对不起。由于我的设置,我无法运行 mvn help:effective-settings...

最佳答案

但不知道为什么,重启nexus进程后,还没真正开始,maven下载进程就继续......

我的环境:centos 7,maven 3.6.3,java-1.8.0-openjdk-1.8.0.302

关于Maven 无法从 Artifactory Repository 下载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28466556/

相关文章:

http - nginx 没有那个文件或目录

artifactory - Pip install 为 Artifactory 上传的包返回 "Could not find a version that satisfies requirement"

java - Maven编译错误: package org. junit不存在

java - Maven Java 项目中文件搜索中的 IntelliJ : Hide . 类文件

java - 在 Jenkins 中显示 OWASP Dependency-Check Maven 插件的结果

Jenkins 正常运行时间 - 自上次重启以来的时间

java - 在多模块maven项目中查找 Unresolved maven依赖项

java - Maven 依赖冲突 : org. w3c.dom.ElementTraversal

Jenkins管道: How to dump errors?

tomcat - Artifactory 和 tomcat 内存不足