通过 Jenkins 构建 Maven 项目并将其部署到 Nexus
Build and Deploy a Maven Project to Nexus via Jenkins
我配置了一个简单的maven freestyle项目。我能够成功构建项目但无法部署到 Nexus。我收到此错误:
[ERROR] 无法执行目标 org.apache.maven.plugins:maven-deploy-plugin:2.8.1:deploy (default-deploy) on project eqs_utility: Failed to deploy artifacts: Could not find工件 com.companyName.eqs:eqs_utility:jar:1.0.1-20190529.191240-1 in nexus (https://nexus.companyRepo.com/repository/maven-snapshot/) -> [帮助 1]
我已经尝试更改配置以简化项目,但仍然没有。 Setting.xml 变化。
已编辑
我将以下内容添加到我的 POM.xml
<distributionManagement>
<repository>
<uniqueVersion>false</uniqueVersion>
<id>nexus</id>
<name>Company Nexus Repository</name>
<url>https://nexus.mycompany.com/repository/maven-release/</url>
</repository>
<snapshotRepository>
<uniqueVersion>true</uniqueVersion>
<id>nexus</id>
<name>Company Nexus Snapshots</name>
<url>https://nexus.companyName.com/repository/maven-snapshot/</url>
</snapshotRepository>
</distributionManagement>
然后,用这个
更新了我的settings.xml
<server>
<id>nexus</id>
<filePermissions>664</filePermissions>
<directoryPermissions>775</directoryPermissions>
</server>
<!-- Another sample, using keys to authenticate. -->
<server>
<id>nexus</id>
<username>NexusUser</username>
<password>MyLongTokenValueHere</password>
</server>
根据Apache Maven Deploy Plugin setup
你需要一个部分:
<distributionManagement>
<repository>
<id>internal.repo</id>
<name>MyCo Internal Repository</name>
<url>Host to Company Repository</url>
</repository>
</distributionManagement>
当您使用 Nexus 时,您可能需要 pom 中的一个部分与您的 nexus 存储库对齐(一个用于快照,一个用于发布工件,因为您不能在 nexus 中组合它们):
<distributionManagement>
<repository>
<id>mavenrepository</id>
<url>http://mavenrepository.companyName.com/nexus/content/repositories/m3</url>
</repository>
<snapshotRepository>
<id>tmavenrepository</id>
<url>http://mavenrepository.companyName.com/nexus/content/repositories/m3-snapshots</url>
</snapshotRepository>
</distributionManagement>
此外,当然,在您的本地设置或其他私人位置
<server>
<id>mavenrepository</id>
<username>maven</username>
<password>foobar</password>
</server>
我配置了一个简单的maven freestyle项目。我能够成功构建项目但无法部署到 Nexus。我收到此错误:
[ERROR] 无法执行目标 org.apache.maven.plugins:maven-deploy-plugin:2.8.1:deploy (default-deploy) on project eqs_utility: Failed to deploy artifacts: Could not find工件 com.companyName.eqs:eqs_utility:jar:1.0.1-20190529.191240-1 in nexus (https://nexus.companyRepo.com/repository/maven-snapshot/) -> [帮助 1]
我已经尝试更改配置以简化项目,但仍然没有。 Setting.xml 变化。
已编辑 我将以下内容添加到我的 POM.xml
<distributionManagement>
<repository>
<uniqueVersion>false</uniqueVersion>
<id>nexus</id>
<name>Company Nexus Repository</name>
<url>https://nexus.mycompany.com/repository/maven-release/</url>
</repository>
<snapshotRepository>
<uniqueVersion>true</uniqueVersion>
<id>nexus</id>
<name>Company Nexus Snapshots</name>
<url>https://nexus.companyName.com/repository/maven-snapshot/</url>
</snapshotRepository>
</distributionManagement>
然后,用这个
更新了我的settings.xml<server>
<id>nexus</id>
<filePermissions>664</filePermissions>
<directoryPermissions>775</directoryPermissions>
</server>
<!-- Another sample, using keys to authenticate. -->
<server>
<id>nexus</id>
<username>NexusUser</username>
<password>MyLongTokenValueHere</password>
</server>
根据Apache Maven Deploy Plugin setup
你需要一个部分:
<distributionManagement>
<repository>
<id>internal.repo</id>
<name>MyCo Internal Repository</name>
<url>Host to Company Repository</url>
</repository>
</distributionManagement>
当您使用 Nexus 时,您可能需要 pom 中的一个部分与您的 nexus 存储库对齐(一个用于快照,一个用于发布工件,因为您不能在 nexus 中组合它们):
<distributionManagement>
<repository>
<id>mavenrepository</id>
<url>http://mavenrepository.companyName.com/nexus/content/repositories/m3</url>
</repository>
<snapshotRepository>
<id>tmavenrepository</id>
<url>http://mavenrepository.companyName.com/nexus/content/repositories/m3-snapshots</url>
</snapshotRepository>
</distributionManagement>
此外,当然,在您的本地设置或其他私人位置
<server>
<id>mavenrepository</id>
<username>maven</username>
<password>foobar</password>
</server>