workflow DSL and parameters validation

55 views
Skip to first unread message

nicolas de loof

unread,
Feb 27, 2015, 11:06:19 AM2/27/15
to jenkin...@googlegroups.com
Hi,

I'm looking into JENKINS-26085 (credentials in workflow `git` keyword)

I'd like to offer some way to validate the ID passed by user as :

git url: 'xx.git', credentialsId:123abc


For this I can use comparable code Git Plugin has in Descriptor validate method. But I don't think workflow do offer such a "validation" - both on groovy DSL to ensure correct syntax + semantic to let each step confirm correct parameters. 

Is this something that has already been considered ?

Jesse Glick

unread,
Feb 27, 2015, 4:29:30 PM2/27/15
to Jenkins Dev
On Fri, Feb 27, 2015 at 11:05 AM, nicolas de loof
<nicolas...@gmail.com> wrote:
> I'd like to offer some way to validate the ID passed by user as :
>
> git url: 'xx.git', credentialsId:123abc

DescriptorImpl.doCheckCredentialsId will be called from the Snippet
Generator, though the main thing that is needed is
doFillCredentialsIdItems, and use <c:select> from config.jelly as
usual.

nicolas de loof

unread,
Feb 27, 2015, 4:42:00 PM2/27/15
to jenkin...@googlegroups.com
sure, if you use snippet generator, that's fine. But I was consider direct DSL edition. Especially when editing an existing one.


--
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/CANfRfr3zqEHFbp3sKzB2mD3oo-mnYiotjuZxbMZVoZPwbqd5qQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Jesse Glick

unread,
Feb 27, 2015, 5:07:45 PM2/27/15
to Jenkins Dev
On Fri, Feb 27, 2015 at 4:41 PM, nicolas de loof
<nicolas...@gmail.com> wrote:
> I was consider direct DSL edition. Especially when editing an existing one.

Well, either your credentialsId is valid, or it is not. If not, the
lookup from CredentialsProvider will fail to find an item with the
matching ID, so you will throw AbortException and that is that.

nicolas de loof

unread,
Feb 28, 2015, 6:17:29 AM2/28/15
to jenkin...@googlegroups.com
sure, so my question is about to validate the DSL script before you actually run the workflow. 
I don't want to have to run my workflow (that may be a complex and long process) dozen times to validate the id is wrong or the syntax is using invalid attribute name as I made a typo. I expect some way to dry-run the workflow so each step just validate attributes I've set.

--
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.

Jesse Glick

unread,
Feb 28, 2015, 1:26:13 PM2/28/15
to Jenkins Dev
On Sat, Feb 28, 2015 at 6:16 AM, nicolas de loof
<nicolas...@gmail.com> wrote:
> my question is about to validate the DSL script before you actually run the workflow.

There is no such system, and I have a hard time imagining how one
would work anyway.

> validate the id is wrong or the syntax is using invalid attribute name as I made a typo

This is what the Snippet Generator is for; or in the future perhaps
DSLD/GDSL as well.

nicolas de loof

unread,
Feb 28, 2015, 2:08:34 PM2/28/15
to jenkin...@googlegroups.com
2015-02-28 19:25 GMT+01:00 Jesse Glick <jgl...@cloudbees.com>:
On Sat, Feb 28, 2015 at 6:16 AM, nicolas de loof
<nicolas...@gmail.com> wrote:
> my question is about to validate the DSL script before you actually run the workflow.

There is no such system, and I have a hard time imagining how one
would work anyway.

Can't the Step API just introduce a "dryRun" or "validate" method, so you can parse and (dry-)run the DSL to collect all configuration | syntax | parameter name/type/value errors
 

> validate the id is wrong or the syntax is using invalid attribute name as I made a typo

This is what the Snippet Generator is for; or in the future perhaps
DSLD/GDSL as well.
--
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.

Jesse Glick

unread,
Feb 28, 2015, 5:21:23 PM2/28/15
to Jenkins Dev

Not in a dynamically-typed language, at least not reliably.

nicolas de loof

unread,
Mar 1, 2015, 2:50:36 AM3/1/15
to jenkin...@googlegroups.com
I don't get how this relates to dynamic typing.

Can't the DSL just be ran, but with some "Global.DRY_RUN=true" so that every step just is no-op, but validates all parameters exists, have reasonable values, etc ?

2015-02-28 23:21 GMT+01:00 Jesse Glick <jgl...@cloudbees.com>:

Not in a dynamically-typed language, at least not reliably.

--
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.

Jesse Glick

unread,
Mar 1, 2015, 7:33:20 PM3/1/15
to Jenkins Dev

Yes but that is not true of the non-step Groovy code, which may have side effects and/or rely on the return values of steps.

Reply all
Reply to author
Forward
0 new messages