Knitschi Knitschi - 12 days ago 6
Groovy Question

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

I am currently trying to transform my former "GUI"-build-steps into a pipeline groovy script. I formerly had a step from the valgrind plugin to publish the results of a valgrind run.

I found the "step: General Build Step" function in the Pipeline Syntax Snippet Generator and tried to use it to create the valgrind publish results step with the following code:

// file pipeline.groovy

import org.jenkinsci.plugins.valgrind.*;

...

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

...


When I run this jenkins complains:

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


So I am not sure if the problem is that
ValgrindPublisher
only derives from
BuildStep
and not from
SimpleBuildStep
or if my import is faulty.

The more general question would be:

Is it possible to run any build-step from a plugin in a pipeline script and if so, where can I find examples?

Answer

No you cannot. You can only use steps from pipelines-compatible plugins and it appears that your ValgrindPublisher plugin is not (yet) pipeline-compatible.

You can check this answer for similar information.

Comments