How to avoid using prebuild() in a pipeline plugin?

20 views
Skip to first unread message

steadyonabix

unread,
Sep 11, 2018, 9:01:45 AM9/11/18
to Jenkins Developers

Hi

 

I’m completely new to plugin development for Jenkins, so please forgive my ignorance while I get up to speed.

 

I’m trying to refactor the OWASPZAP Jenkins plugin to support the “pipeline” or “workflow” syntax.

This plugin currently uses the prebuild() method to configure and start a standalone Java application, the OWASPZAP scanner.

 

I watched the Youtube video on refactoring for pipeline and it highlighted the need to avoid using prebuild() as it presupposes a specific run order.

 

My question is, if I don’t use prebuild() to configure and kick off this application, how do I do it?

Is the convention to create a separate stage in the pipeline or something?

 

Thanks in advance

 

steady

Jesse Glick

unread,
Sep 11, 2018, 11:44:12 AM9/11/18
to Jenkins Dev
On Tue, Sep 11, 2018 at 9:01 AM steadyonabix <bradley...@gmail.com> wrote:
> This plugin currently uses the prebuild() method to configure and start a standalone Java application, the OWASPZAP scanner.

Probably this should simply be folded into your `SimpleBuildStep.perform`.

(If you really need to have something that runs before and after the
build as a whole for some reason, you can create a
`[Simple]BuildWrapper`. But I cannot see how that would be the case
here.)

> I watched the Youtube video on refactoring for pipeline and it highlighted the need to avoid using prebuild() as it presupposes a specific run order.

Noted in: https://javadoc.jenkins.io/jenkins/tasks/SimpleBuildStep.html

steadyonabix

unread,
Sep 12, 2018, 4:18:25 AM9/12/18
to Jenkins Developers
Thanks Jesse,

With hindsight, an obvious solution. :)

I think the simple build step wouldn't help, as I would then have to ensure that it was run first, thereby reintroducing the specific run order.

Thanks again

Jesse Glick

unread,
Sep 12, 2018, 2:39:35 PM9/12/18
to Jenkins Dev
On Wed, Sep 12, 2018 at 4:18 AM steadyonabix <bradley...@gmail.com> wrote:
> I think the simple build step wouldn't help, as I would then have to ensure that it was run first, thereby reintroducing the specific run order.

You cannot have a step which configures and starts the scanner, runs
it on whatever, and then shuts it down? Why does this need to be
complicated?

steadyonabix

unread,
Sep 13, 2018, 3:51:34 AM9/13/18
to Jenkins Developers
Sorry, I thought that was what I was saying. I should have been clearer.
Reply all
Reply to author
Forward
0 new messages