简体   繁体   English

通过Jenkins的Maven Project jar版本

[英]Maven Project jar version through Jenkins

I'm currently working on setting up a continuous integration environment that will use git as the source and Nexus as the Artifact repository. 我目前正在建立一个持续集成环境,该环境将使用git作为源,使用Nexus作为Artifact存储库。

I have configured 2 jobs in Jenkins. 我在詹金斯(Jenkins)配置了2个工作。

  1. A maven build job that will parse the pom file in git and deploy the jar file to Nexus. 一个Maven构建作业,它将解析git中的pom文件并将jar文件部署到Nexus。
  2. A deploy job that will deploy the jar file from Nexus to application server(weblogic) 部署作业会将jar文件从Nexus部署到应用程序服务器(weblogic)

I need help in the below 2 areas. 我需要以下2个方面的帮助。

1) When the jar is deployed to Nexus, the file will be in the format: -0.0.1-date&time-1.jar 1)将jar部署到Nexus时,文件格式为:-0.0.1-date&time-1.jar

Is there any way that i can modify this to just fileName.jar? 有什么办法可以将其修改为fileName.jar?

2) How do i setup the 2nd job to pick the jar file created by the first job? 2)我如何设置第二个作业以选择第一个作业创建的jar文件? I'm looking for ways by which i can pass the version number to the deploy job dynamically. 我正在寻找可以将版本号动态传递给部署作业的方法。

Files in Maven repository are versioned and have a standardized format. Maven存储库中的文件已版本化,并具有标准化格式。 The format you've outlined is for SNAPSHOT revisions, explaining the time-stamp. 您概述的格式适用于SNAPSHOT修订版,解释了时间戳。 Try setting a real number in the "version" field of the POM and you'll see the difference. 尝试在POM的“版本”字段中设置一个实数,您将看到差异。

I have never used it, but I suggest trying the Maven Metadata plugin to create a drop-down list of versions, in a parametrized job. 我从未使用过它,但是我建议尝试在参数化工作中尝试使用Maven Metadata插件来创建版本的下拉列表。

Do you really need two jobs? 您真的需要两项工作吗? I'd rather use the Promoted Builds Plugin to deploy the artifact — this can be done based on some rule or automatically. 我宁愿使用Promoted Builds插件来部署工件-这可以基于某些规则或自动完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM