Pipeline snippet generator: How to format generated snippet text?

26 views
Skip to first unread message

Martin Weber

unread,
May 21, 2019, 4:33:23 PM5/21/19
to jenkin...@googlegroups.com
Hi all,

I see the snippet generator prints a nicely formatted code for the withEnv
step.
How can I tell the snippet generator to do that for my pipeline step, too?
Any pointer to docs or code are welcome.

Martin

--
Cd wrttn wtht vwls s mch trsr.




Robert Sandell

unread,
May 22, 2019, 4:38:46 AM5/22/19
to jenkin...@googlegroups.com
You need a config.jelly (and help-field.html) file for your step and the rest should be done for you by magic.

/B

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/2361528.TRu7gUjnlG%40linux.
For more options, visit https://groups.google.com/d/optout.


--
Robert Sandell
Software Engineer
CloudBees, Inc.
CloudBees-Logo.png
Twitter: robert_sandell

Jesse Glick

unread,
May 29, 2019, 9:23:14 PM5/29/19
to Jenkins Dev
On Wed, May 22, 2019 at 4:38 AM Robert Sandell <rsan...@cloudbees.com> wrote:
> the rest should be done for you by magic.

Magic favors the well prepared!

https://jenkins.io/doc/developer/plugin-development/pipeline-integration/

Martin Weber

unread,
May 30, 2019, 9:30:27 AM5/30/19
to jenkin...@googlegroups.com
Am Mittwoch, 22. Mai 2019, 10:38:29 CEST schrieb Robert Sandell:
> You need a config.jelly (and help-field.html) file for your step and the
> rest should be done for you by magic.

Sorry, if my question was not precise.
For the withEnv step, the snippets generator puts nicely formatted text in the
text box like this:

withEnv([var=val]) {
// some stuff
}

For my step, the snippet generator prints everything on a single line:

cmakeBuild buildDir: 'build', installation: 'InSearchPath', sourceDir: 'src',
steps: [[args: 'all']]


I tried to override StepDescriptor#argumentsToString(Map<String, Object>) but
that method is never invoked. My Jenkins version is 2.150.3 and workflow-
aggregator is 2.5

Martin


--
E-Mails sollten Text sein, Text und nur Text.
Wenn Gott gewollt hätte, dass E-Mails in HTML geschrieben würden,
endeten Gebete traditionell mit </amen>.


Jesse Glick

unread,
May 30, 2019, 9:50:52 AM5/30/19
to Jenkins Dev
On Thu, May 30, 2019 at 9:30 AM Martin Weber <fifteen...@gmail.com> wrote:
> For my step, the snippet generator prints everything on a single line:

Because your step is not block-scoped.

> cmakeBuild buildDir: 'build', installation: 'InSearchPath', sourceDir: 'src',
> steps: [[args: 'all']]

Looks fine to me, assuming the above syntax indeed works.

Martin Weber

unread,
May 30, 2019, 12:13:24 PM5/30/19
to jenkin...@googlegroups.com
Am Donnerstag, 30. Mai 2019, 15:50:36 CEST schrieb Jesse Glick:
> On Thu, May 30, 2019 at 9:30 AM Martin Weber <fifteen...@gmail.com>
wrote:
> > For my step, the snippet generator prints everything on a single line:
> Because your step is not block-scoped.

Thanks for the clarification.
Reply all
Reply to author
Forward
0 new messages