简体   繁体   English

Jenkins-丢弃/保留参数化构建的工件

[英]Jenkins - discard/keep artifacts of a parameterized build

In Jenkins (or Hudson), I set up a pipeline of parameterized jobs, say A -> B, that copy artifacts from each other using the Copy Artifact Plugin. 在Jenkins(或Hudson)中,我建立了一个参数化作业的流水线,例如A-> B,它们使用Copy Artifact Plugin互相复制工件。 All jobs use the same parameter, eg the target platform. 所有作业都使用相同的参数,例如目标平台。 Each job is set to discard old builds and artifacts to limit disk usage, keeping only the latest stable build artifacts. 每个作业都设置为丢弃旧版本和工件,以限制磁盘使用,仅保留最新的稳定版本工件。 I use parameterized builds to avoid having to maintain many jobs that only differ in the parameter setting. 我使用参数化构建,以避免必须维护许多仅在参数设置上有所不同的作业。

This setup only works if all builds run after each other in a pipeline with the same parameter settings, and hence the latest build artifacts match the platform parameter setting of a dependent job. 仅当所有构建都在具有相同参数设置的管道中相互运行时,此设置才有效,因此最新的构建工件与从属作业的平台参数设置匹配。 Now if someone first builds job A for platform x, and then for platform y, then builds B for platform x, the artifacts from A for platform x are already discarded and hence B cannot copy these. 现在,如果有人先为平台x构建作业A,然后为平台y构建作业,然后为平台x构建作业B,则已经丢弃了来自A的针对平台x的工件,因此B无法复制这些工件。

Is there a way to tell Jenkins to keep the latest artifacts for each build with different parameters and discard all others? 有没有一种方法可以告诉Jenkins使用不同的参数保留每个构建的最新工件,并丢弃所有其他工件?

Manual solution: copy the artifacts from A into a directory that is keyed by the parameters. 手动解决方案:将工件从A复制到由参数键入键的目录中。 Job A will clean out the directory before the build - and thus make sure that stale artifacts do not pass to job B. Job B will clean out the directory after it runs in any case. 作业A将在构建之前清除目录-从而确保陈旧的工件不会传递给作业B。无论如何,作业B将在目录运行后清除目录。

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

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