Sonatype Nexus:无法从/向往/向联系转移工件,拒绝访问,ReasonPhrase:禁止

时间:2019-03-14 09:03:58

标签: maven package repository nexus sonatype

我正在尝试设置Nexus maven代理存储库,并构建一个小型开源应用程序,以查看它是否通过我的本地关系实例。

我有一个正在运行的Nexus本地实例,并且按照此this lesson

创建了一个maven-proxy-test remository

这是我的settings.xml:

<settings>
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/repository/maven-proxy-test/</url>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://localhost:8081/repository/maven-proxy-test/</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://localhost:8081/repository/maven-proxy-test/</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
    <proxies>
   <proxy>
      <id>ullink-proxy-id</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>proxy.ullink.lan</host>
      <port>9876</port>
      <nonProxyHosts>*.ullink.lan</nonProxyHosts>
    </proxy>
    <proxy>
      <id>ullink-proxy-id2</id>
      <active>true</active>
      <protocol>https</protocol>
      <host>proxy.ullink.lan</host>
      <port>9876</port>
      <nonProxyHosts>*.ullink.lan</nonProxyHosts>
    </proxy>
  </proxies>
</settings>

然后我克隆了this jenkins插件并尝试运行

mvn package

输出为:

[INFO] Scanning for projects...
Downloading: http://localhost:8081/repository/maven-proxy-test/org/jenkins-ci/plugins/plugin/3.1/plugin-3.1.pom
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for org.jenkins-ci.plugins:parameterized-trigger:2.35.3-SNAPSHOT: Could not transfer artifact org.jenkins-ci.plugins:plugin:pom:3.1 from/to nexus (http://localhost:8081/repository/maven-proxy-test/): Access denied to: http://localhost:8081/repository/maven-proxy-test/org/jenkins-ci/plugins/plugin/3.1/plugin-3.1.pom , ReasonPhrase:Forbidden. and 'parent.relativePath' points at no local POM @ line 4, column 13
 @ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project org.jenkins-ci.plugins:parameterized-trigger:2.35.3-SNAPSHOT (C:\projects\parameterized-trigger-plugin\pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM for org.jenkins-ci.plugins:parameterized-trigger:2.35.3-SNAPSHOT: Could not transfer artifact org.jenkins-ci.plugins:plugin:pom:3.1 from/to nexus (http://localhost:8081/repository/maven-proxy-test/): Access denied to: http://localhost:8081/repository/maven-proxy-test/org/jenkins-ci/plugins/plugin/3.1/plugin-3.1.pom , ReasonPhrase:Forbidden. and 'parent.relativePath' points at no local POM @ line 4, column 13 -> [Help 2]
[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/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException

P.S。我在Nexus Administrator中配置的公司代理后面。 任何帮助深表感谢!

1 个答案:

答案 0 :(得分:0)

通过将localhost添加到nonProxyHosts来工作

<nonProxyHosts>localhost|127.0.0.1</nonProxyHosts>