我可以使用 step() 从任何插件创建任何构建步骤吗?

Can I use step() to create any build-step from any plugin?

我目前正在尝试将我以前的 "GUI"-build-steps 转换为管道 groovy 脚本。我以前从 valgrind plugin 一步发布了一个 valgrind 运行.

的结果

我在 Pipeline Syntax Snippet Generator 中找到了 "step: General Build Step" 函数,并尝试使用它通过以下代码创建 valgrind 发布结果步骤:

// file pipeline.groovy

import org.jenkinsci.plugins.valgrind.*;

...

node('Publish Valgrind results')
{
    step([$class: 'ValgrindPublisher', ValgrindPublisherConfig: [$class: 'ValgrindPublisherConfig', pattern: 'CppCodeBase/Generated/ValgrindOutput/**']])
}

...

当我 运行 这个詹金斯抱怨时:

java.lang.UnsupportedOperationException: no known implementation of interface jenkins.tasks.SimpleBuildStep is named ValgrindPublisher

所以我不确定问题是 ValgrindPublisher 仅来自 BuildStep 而不是来自 SimpleBuildStep 还是我的导入有误。

更一般的问题是:

是否可以运行管道脚本中插件的任何构建步骤?如果可以,我在哪里可以找到示例?

不,你不能。您只能使用 pipelines-compatible plugins 中的步骤,并且您的 ValgrindPublisher 插件似乎(还)不兼容管道。

您可以查看 以获取类似信息。