我正在尝试使用Nexus Jenkins插件上传其pom文件的发布工件。
Nexus存储库配置了部署策略"禁用重新部署"这样就不能覆盖发布。
为了简化问题,想象一下我只想上传我的自定义pom:
pipeline {
agent any
stages {
stage('Publish') {
steps {
nexusPublisher nexusInstanceId: 'nexusJose', nexusRepositoryId: 'nexusJose',
packages: [
[$class: 'MavenPackage',
mavenAssetList: [
[classifier: '',
extension: 'pom',
filePath: "/libs/mylib-4.6.0.pom"],
],
mavenCoordinate: [
artifactId: "mylib",
groupId: "com.codependent.libs",
packaging: "pom", version: "4.6.0"]
]
]
}
}
}
}
出于某种原因,当nexusPublisher执行时,Nexus在执行pom上传之前为这些坐标创建了默认pom,因此实际pom的上传失败,因为它已存在于存储库中:
Uploading Maven asset with groupId: mylib artifactId: com.codependent.libs version: 4.6.0 To repository: thirdparty
Upload of /libs/mylib-4.6.0.pom failed
Failing build due to failure to upload file to Nexus Repository Manager Publisher
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
com.sonatype.nexus.api.exception.RepositoryManagerException: Unable to upload component: Bad Request <html><body><error>Repository with ID='thirdparty' does not allow updating artifacts.</error></body></html>
如何使用自己的pom上传工件?
答案 0 :(得分:0)
实际上,您不需要配置上传pom.xml文件-Nexus Jenkins插件会自动上传您的pom.xml文件。您只需要配置发布工件的上传。
因此,您可以使用以下配置,并且应自动上传“ mylib-4.6.0.pom”:
pipeline {
agent any
stages {
stage('Publish') {
steps {
nexusPublisher nexusInstanceId: 'nexusJose', nexusRepositoryId: 'nexusJose',
packages: [
[$class: 'MavenPackage',
mavenAssetList: [
[classifier: '',
extension: '',
filePath: "${path-to-artifact}/mylib-4.6.0.jar"],
],
mavenCoordinate: [
artifactId: "mylib",
groupId: "com.codependent.libs",
packaging: "jar", version: "4.6.0"]
]
]
}
}
}
}
此页面可能有用: https://support.sonatype.com/hc/en-us/articles/227256688-How-do-I-configure-the-Nexus-Jenkins-Plugin