为maven部署配置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时创建的默认管理用户(user/pw是正确的,使用同一用户登录nexus(。与创建存储库的用户相同。

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

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

这个愚蠢的错误我早该注意到的。

最新更新