简体   繁体   English

Jenkins-从远程存储库获取最新的工件版本

[英]Jenkins - get latest artifact version from remote repository

I'm trying to create a deploy job in Jenkins. 我正在尝试在詹金斯创建一个部署作业。 Up until now I was building my artifact via the maven install goal and then deploying it on the application server with a shell script. 到目前为止,我是通过maven安装目标构建工件的,然后使用Shell脚本将其部署在应用程序服务器上。 However, I'd now like to skip the install part and just get the artifact from my nexus repository. 但是,我现在想跳过安装部分,而只是从nexus存储库中获取工件。

I know there is the maven dependency:get which I can use to retrieve the artifact from the repository but is there any way I can make sure I'll get the latest version without passing it as a build parameter? 我知道有一个Maven依赖项:get,我可以使用它来从存储库中检索工件,但是有什么方法可以确保我将最新版本而不将其作为构建参数传递吗?

You have different options: 您有不同的选择:

1) Use the Repository Connector Plugin . 1)使用存储库连接器插件 With this plugin, you get an additional "Artifact Resolver" build step, where you can download an artifact from a centrally configured (Manage Jenkins) repository to the workspace of your deploy job (with different options like renaming etc). 使用此插件,您将获得一个额外的“工件解析器”构建步骤,您可以在其中从集中配置的(管理Jenkins)存储库中将工件下载到部署作业的工作空间中(使用诸如重命名等其他选项)。

If you use the version LATEST , you always get the latest version. 如果使用LATEST版本,则始终会获得最新版本。 Likewise, you can use RELEASE for the latest release version or ranges like [1.0,1.1) . 同样,您可以将RELEASE用于最新发行版本或范围[1.0,1.1)

There are two caveats however: 但是,有两个警告:

In the newest version of the plugin, LATEST is broken (see https://issues.jenkins-ci.org/browse/JENKINS-20263 ), so you need to use version 0.8.2 for now). 在该插件的最新版本中, LATEST已损坏(请参阅https://issues.jenkins-ci.org/browse/JENKINS-20263 ,因此您现在需要使用0.8.2版本)。

You should manually fingerprint the downloaded artifact, since this is not automatically done right now. 您应该手动对下载的工件进行指纹识别,因为这不会立即自动完成。

2) Use dependency:get as suggested, but use LATEST or RELEASE as above. 2)使用dependency:按照建议进行获取,但如上所述使用LATESTRELEASE However, I do not think this is a really elegant solution. 但是,我认为这不是一个真正的优雅解决方案。 (if you simply use SNAPSHOTs with the same base version, follow khmarbaise's advice and simply add -U to the commandline) (如果您仅使用具有相同基本版本的SNAPSHOT,请按照khmarbaise的建议,并在命令行中简单地添加-U)

3) Use the Maven Deployment Linker Plugin plugin, which is a rather elegant alternative, since you can copy artifacts from other jobs like Copy-Artifact, but they are still retrieved from your Artifact repository (thus you do not waste diskspace and time). 3)使用Maven Deployment Linker插件插件,这是一个相当不错的选择,因为您可以从其他作业(如Copy-Artifact)复制工件,但是仍然可以从Artifact存储库中检索它们(因此,您不会浪费磁盘空间和时间)。 The largest problem with that plugin is that it currently does not support authentification. 该插件的最大问题是它当前不支持身份验证。

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

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