jenkins - 问:如何使用 groovy 管道将工件保存到 Nexus 存储库中?
问题描述
我的问题是关于将工件保存到存储库中。特别是,在为 Maven 项目(通过 Jenkins)执行构建管道之后,我试图上传到 Nexus Repository 工件和发布版本。
我想要这样做的唯一方法就是使用用 Groovy 编写的管道以便与 Jenkins 集成。
注意:我希望工件版本号始终相同,并且版本号动态更改(而不是手动)。
通常是否有命令或代码可以让我做到这一点?
解决方案
您处于错误的级别,这应该发生在 Maven 中。在 pom.xml 你需要。(更多在这里)
<distributionManagement>
<snapshotRepository>
<id>nexus-snapshots</id>
<url>http://localhost:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
然后在插件部分
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
你应该能够mvn clean deploy
从你的管道中做。
编辑Nexus Artifact Uploader 插件 还有另一种方法
nexusArtifactUploader {
nexusVersion('nexus2')
protocol('http')
nexusUrl('localhost:8080/nexus')
groupId('sp.sd')
version("2.4.${env.BUILD_NUMBER}")
repository('NexusArtifactUploader')
credentialsId('44620c50-1589-4617-a677-7563985e46e1')
artifact {
artifactId('nexus-artifact-uploader')
type('jar')
classifier('debug')
file('nexus-artifact-uploader.jar')
}
artifact {
artifactId('nexus-artifact-uploader')
type('hpi')
classifier('debug')
file('nexus-artifact-uploader.hpi')
}
}
推荐阅读
- android - 无法在android中使用对话框
- macos - Electron 应用在 Apple 评测中显示黑屏
- php - Laravel 6 下拉搜索过滤器
- amazon-web-services - 无法访问 AWS SQS
- git - 如何删除 git repo 中的重复文件?
- excel - 如何在excel中仅提取月末日期的数据?
- python - 根据其他列的值为 Pandas Dataframe 创建列
- django - 为什么在 Django i18n 中使用 domain.com 而不是 domain.com/en/ 时会出现错误 500?
- javascript - React Memo 更新父组件状态
- c - 无法在 Visual Studio C 程序上使用 OCILIB 连接到数据库