简体   繁体   English

使用 Jenkins、Artifactory、Maven 自定义构建标记

[英]Custom build tagging with Jenkins, Artifactory, Maven

I'm working on a strategy to tag builds in my continuous integration and delivery pipeline.我正在制定一种策略来标记我的持续集成和交付管道中的构建。 When a fresh build is produced it then goes through multiple stages of testing;生成新版本后,它会经历多个测试阶段; after each stage I would like to tag the build.在每个阶段之后,我想标记构建。 My idea was to expand on the standard Maven system, so an example would be:我的想法是扩展标准的 Maven 系统,所以一个例子是:

my-artifact-1.0-SNAPSHOT.jar
my-artifact-1.0-PASSED_TESTS_1.jar
my-artifact-1.0-PASSED_TESTS_2.jar
...
my-artifact-1.0-RELEASE.jar

As a build passes each stage its tag, which is part of its name/version, gets updated.当构建通过每个阶段时,其标记(其名称/版本的一部分)会更新。 Eventually, after all testing stages the build is tagged as releasable with RELEASE.最终,在所有测试阶段之后,构建被标记为可发布与 RELEASE。

I'm using a Jenkins server and storing artifacts on Artifactory (non-Pro) in Maven repositories.我正在使用 Jenkins 服务器并将工件存储在 Maven 存储库中的 Artifactory(非 Pro)上。 My plan is to use separate Maven repositories for each tag type above, and to move an artifact from one to the other as its tag is updated.我的计划是为上面的每种标记类型使用单独的 Maven 存储库,并在更新标记时将工件从一个移动到另一个。

My pseudo-code for the promotion looks like:我的促销伪代码如下所示:

(1) Download artifacts that passed in Jenkins 
(2) Text-replace the tag (maybe pom.xml as well?)
(3) Upload to new repository
(4) Update the associated Git commit with tag also

I'm not sure how to actually implement this cleanly - is this a common way of doing things?我不确定如何真正干净地实现这一点 - 这是一种常见的做事方式吗? Am I missing something important?我错过了什么重要的东西吗? Can a Jenkins + Artifactory (non-Pro) + Maven (repos only, Gradle for builds) system accomplish this? Jenkins + Artifactory(非专业版)+ Maven(仅存储库,用于构建的 Gradle)系统可以完成此任务吗?

Thanks!谢谢!

I can see where the idea of adding more metadata to the file names come.我可以看到向文件名添加更多元数据的想法来自哪里。 Usually, we don't have any other place to add this kind of information, except of the name.通常,除了名称之外,我们没有任何其他地方可以添加此类信息。 But with a proper artifact repository manager (as Artifactory), you don't need it anymore.但是有了合适的工件存储库管理器(作为 Artifactory),您就不再需要它了。 You can attach any metadata to the artifacts in the repository manager, and then manipulate (eg promote) the artifacts based on those properties.您可以将任何元数据附加到存储库管理器中的工件,然后根据这些属性操作(例如提升)工件。

Here's a screencast showing what it takes to add this kind of metadata to the artifacts, and how to promote artifacts based on it. 这是一个截屏视频,显示了将这种元数据添加到工件中需要什么,以及如何基于它提升工件。

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

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