简体   繁体   English

Jenkins 工件在复制时损坏

[英]Jenkins artifacts corrupted when copied

I'm setting up a Jenkins declarative pipeline, where I need to copy an artifact from a different job.我正在建立一个 Jenkins 声明性管道,我需要从不同的工作中复制工件。 The artifact is of substantial size, 10.8 M, and seems to get corrupted when copied.该工件相当大,有 10.8 M,并且在复制时似乎已损坏。 I save the copied artifact again as an artifact in the second job and see the size as 10.78 M. Is there any reason for this behaviour or ways to avoid it?我再次将复制的工件保存为第二个作业中的工件,并看到大小为 10.78 M。这种行为是否有任何原因或避免它的方法?

The resulting code from the pipeline seems corrupted and a byte-by-byte comparison reveals differences between the artifact in the first and second jobs.来自管道的结果代码似乎已损坏,逐字节比较揭示了第一个和第二个作业中工件之间的差异。

I use the Copy Artifact Plugin for Jenkins like so:我像这样使用 Jenkins 的 Copy Artifact 插件:

step ([$class: 'CopyArtifact',
projectName: 'First_Job',
filter: '**/*.rbf',
fingerprintArtifacts: true,
target: '.',
])

And I save the artifact for the second time like this:我第二次像这样保存工件:

archiveArtifacts artifacts: 'My_Artifact.rbf', fingerprint: true

The artifact is copied and renamed on the system using a bat script between copying to the second job and archiving again.在复制到第二个作业和再次存档之间,使用bat脚本在系统上复制和重命名工件。

After digging around on the second build machine, I've found that the problem was a 'bug' in the Copy Artifact plugin.在第二台构建机器上挖掘之后,我发现问题是 Copy Artifact 插件中的一个“错误”。 The copied artifact wasn't being cleaned up correctly after each build and the plugin doesn't overwrite the previous artifact, nor does it give a message saying it can't overwrite a file.复制的工件在每次构建后都没有被正确清理,插件不会覆盖以前的工件,也没有给出一条消息说它不能覆盖文件。

This gave the appearance of a successful copy while the pipeline used the old artifact.当管道使用旧工件时,这看起来像是一个成功的副本。

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

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