如何使用管道作业的 CopyArtifact 插件传递从中复制工件的内部版本号?

How to pass build number from which artifacts are copied using CopyArtifact plugins for Pipeline Job?

如何在管道作业中传递从中复制工件的内部版本号? 因为默认此步骤从上一个稳定版本复制工件,我需要从特定版本(例如 123)复制工件。

我的管道代码在这里:

node {
  stage "Copy artifacts"
  step ([$class: 'CopyArtifact',
          projectName: 'other-project',
          filter: 'myapp.jar']);
}

来自官方博客post:

All other config options that the copyartifact-plugin supports are also available. The easiest way to test/browse all options is through the Workflow script “Snippet Generator” (available on the workflow configuration screen below the workflow script textarea).

如果可以参数化,内置 "Snippet Generator" 中应该有适当的选项。

要从特定版本复制工件,您需要另外使用 selector 参数:

node {
  stage "Copy artifacts"
  step ([$class: 'CopyArtifact',
          projectName: 'other-project',
          filter: 'myapp.jar', 
          selector: [$class: 'SpecificBuildSelector', buildNumber: '1']
        ]);
}