validating-string-parameter plugin and pipeline compatibility

966 views
Skip to first unread message

Juri Lelli

unread,
Mar 26, 2018, 1:22:18 PM3/26/18
to jenkin...@googlegroups.com
Hi,

I'm trying to make validating-string-parameter-plugin [1] work with
Jenkins Pipelines.

So far I've managed to get it "working" by throwing a raw
RuntimeException from the @Override buildEnvironment [2]. But this is
far from optimal, as AFAIU buildEnvironment shouldn't be dealing with
parameters valitation at all. The problem with the current version of
the plugin instead is that runtime validation is performed by setUp
method of BuildWrapper(), which doesn't get invoked when using
Pipelines.

So, ideally I would actually like to prevent user hitting "Build" button
if form validation wasn't OK. Is there a way to perform realtime
validation (validation is currently performed when the field looses
focus) and grey out "Build" button if validation didn't succeed?

Alternatively, I was thinking that ParameterDefinition:createValue()
might be changed to possibly throw some form of exception
(AbortException maybe?) if something was wrong at the time user hit
"Build". Of course this would require Jenkins' core mods, would that be
a reasonable and acceptable approach?

Thanks in advance for your help!

Best,

- Juri

[1] https://github.com/jenkinsci/validating-string-parameter-plugin
[2] https://github.com/jlelli/validating-string-parameter-plugin/commit/c76ec48b645fb5315c064bf23553e708f671c530#diff-7f2cc2852df243adfa24654a14dc3d5cR94
[3] https://github.com/jenkinsci/validating-string-parameter-plugin/blob/master/src/main/java/hudson/plugins/validating_string_parameter/ValidatingStringParameterValue.java#L73

Jesse Glick

unread,
Mar 26, 2018, 1:45:05 PM3/26/18
to Jenkins Dev
On Mon, Mar 26, 2018 at 1:20 PM, Juri Lelli <juri....@redhat.com> wrote:
> ideally I would actually like to prevent user hitting "Build" button
> if form validation wasn't OK. Is there a way to perform realtime
> validation (validation is currently performed when the field looses
> focus) and grey out "Build" button if validation didn't succeed?

Not that I am aware.

> I was thinking that ParameterDefinition:createValue()
> might be changed to possibly throw some form of exception
> (AbortException maybe?)

Try throwing `Failure`.

Juri Lelli

unread,
Mar 30, 2018, 6:14:36 AM3/30/18
to Jenkins Developers
Reply all
Reply to author
Forward
0 new messages