配置Nexus连接以进行Maven部署

时间:2020-10-26 14:13:08

标签: maven teamcity nexus

我正在尝试获取与Nexus和TeamCity合作的经验。 为此,我将两台服务器都设置在本地计算机上,并在私人仓库中的github.com上配置了一个宠物项目。

但是我无法运行TC-Build,因为Maven部署步骤失败并显示以下消息。

[14:58:55][Step 2/2] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project Worm: Failed to deploy artifacts: Could not transfer artifact org.test.worm:Worm:jar:1.0.0 from/to local_nexus (http://localhost:8081/repository/org.test): Transfer failed for http://localhost:8081/repository/org.test/org/test/worm/Worm/1.0.0/Worm-1.0.0.jar 401 Unauthorized

似乎由于授权配置错误而失败,但我找不到错误。
在我的项目pom.xml中,它的配置如下

<distributionManagement>
    <repository>
        <id>local_nexus</id>
        <name>Deployment</name>
        <url>http://localhost:8081/repository/org.test</url>
    </repository>
</distributionManagement>

在我的Mavens settings.xml中像这样

<server>
  <id>local_nexus</id>
  <username>admin</username>
  <password>admin</password>
</server>

我使用的是安装nexus时创建的默认admin用户(user / pw是正确的,使用同一用户登录nexus)。创建存储库的同一用户。

TC在localhost:8080下运行,而Nexus在localhost:8081下运行
请告诉我我配置错误或忘记了什么。

1 个答案:

答案 0 :(得分:0)

使用mvn help:effective-settings,我可以确认settings.xml配置正确。但是,这让我意识到,TeamCity Server使用的本地实例与自己的本地实例不同。因此,解决方案是为TeamCity设置maven-home或配置其他maven实例的settings.xml。

我应该早点注意到愚蠢的错误。