Child pages
  • Validating String Parameter Plugin
Skip to end of metadata
Go to start of metadata

Plugin Information

View Validating String Parameter on the plugin site for more information.

The validating string parameter plugin contributes a new parameter type to Jenkins that supports regular expression validation of the user's entered parameter.

Usage

This plugin is used wherever build parameter selection is available, most commonly in the job configuration page by enabling parameterized builds (this parameter type will also be available as release parameters using the release plugin).

Configure the parameter by entering a name, regular expression to validate the entered value and optionally a default value, an error message shown when the user entered value fails the regular expression check and a parameter description.

 
When a build is requested, the user will be prompted with the parameters to enter.  Users enter the parameter as normal, but will now be prompted with an error message if the entered value does not meet the regular expression.

Once the entered value meets the configured regular expression, the error message is no longer displayed.

Version History

Version 2.4 (TBD)

Version 2.3 (04-Feb-2015)

  • Fixed links to regex pattern documentation
  • Use codemirror for the description field

Version 2.2 (13-Sep-2011)

Version 2.1 (27-Feb-2011)

  • If an invalid value is passed to the build, the build will be aborted and an error message will display in console indicating the parameter and failing value

Version 2.0 (19-Feb-2011)

  • Migrated code to jenkins and performed release

Version 1.4 (13-Oct-2010)

  • JENKINS-7794 validation check doesn't work if Jenkins is hosted with a context root

Version 1.3 (22-May-2010)

  • JENKINS-6158 Build will fail if invalid parameter is passed
  • JENKINS-6160 Jenkins will record regex used to validate the build parameter as part of build configuration and display as tooltip on the parameter page.

Version 1.2 (29-Aug-2009)

  • Used the javascript function encodeURIComponent to properly handle characters within the user entered values for regex and validation error message. (Issue 4334

Version 1.1 (28-Aug-2009)

  • Supported the release plugins as well as any other plugin that uses build parameters

Version 1.0 (24-Aug-2009)

  • Initial Version

 

16 Comments

  1. Unknown User (arindamroy@yahoo.com)

    I get the following error message when I try to execute a job with a Validating String Parameter.
    ===================================
    HTTP Status 404 - /descriptor/hudson.plugins.validating_string_parameter.ValidatingStringParameterDefinition/validate

    type Status report

    message /descriptor/hudson.plugins.validating_string_parameter.ValidatingStringParameterDefinition/validate

    description The requested resource (/descriptor/hudson.plugins.validating_string_parameter.ValidatingStringParameterDefinition/validate) is not available.

    Apache Tomcat/6.0.20
    ===================================

    I am using Hudson Version 1.334.
    I have the following plugins installed at the moment:
    email-ext, Plugin:maven-plugin, Plugin:regexemail, Plugin:scis-ad, Plugin:ssh-slaves, Plugin:subversion, Plugin:validating-string-parameter

    1. Unknown User (jheckel@uillinois.edu)

      Is there any chance of this issue getting fixed? I have the same problem and am running Hudson 1.353.

      HTTP Status 404 - /descriptor/hudson.plugins.validating_string_parameter.ValidatingStringParameterDefinition/validate


      type Status report

      message/descriptor/hudson.plugins.validating_string_parameter.ValidatingStringParameterDefinition/validate

      descriptionThe requested resource (/descriptor/hudson.plugins.validating_string_parameter.ValidatingStringParameterDefinition/validate) is not available.


      Apache Tomcat/5.5.9

      1. I'm not sure what isn't working for you.  I was able to run with 1.353.  I have released 1.3 so you can try again with that version.

  2. Hello everyone
    In our company we have set up two server running hudson covering two development branches.
    I discovered this plugin yesterday and must say, it would solves a big problem we have with our configuration.
    The problem is that the actual behaviour is not what one would expect. From my point of view its totally useless to validate a parameter
    and show an error messeage when afterwards I will still be able to hit the build button.
    Is it possible to disable the build button until the parameter has been successfully validated and the error message has gone?
    Actually using Hudson v1.336 with validating-string-parameter plugin v1.2
    Best regards
    Pasquale

    1. I have improved the plugin to fail the build if the parameter doesn't pass.  It isn't nice looking but the error message is there.  I think I'd need to change Hudson core to do something prettier.

      1. At some point, the parameter extension point was granted new abilities and it is now possible for me to abort the build and display an error to the user in the console.  This is much nicer.

  3. On Hudson 1.339 and 1.342 this plugin does not work.

    I've tried with my regexp and also with the one in example here, but when I try to insert a value that clearly did not match, no message is shown.

    I'm trying with FF and all the Javascripts are enabled...

    Regards,

    Andrea

    1. You have to change focus off the text field.  Maybe that's why the message wasn't showing?

  4. It seems only 1.2 version can be used, any other newer versions, will cause errors, when the error will be fixed?

    We need this useful plugin indeed...

  5. Guys who created this plugin or who manages Jenkins plugin section, either fix this plugin or remove it as not working!

  6. I have found that calling my jenkins server without full dns causes this plugin to fail on the build page and display the string "ERROR"

    for example;

    fails;

    http://jenkins:8080/job/Test_Tool/build?delay=0sec

    works;

    http://jenkins.somedomain.com:8080/job/Test_Tool/build?delay=0sec

    worked around this by putting it behind apache and redirecting the URL to use the full domain

    error in logs is this;

    Error while serving http://jenkins.somedomain.com:8080//descriptor/hudson.plugins.validating_string_parameter.ValidatingStringParameterDefinition/validate
    java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:297)
    at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:160)
    at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:95)
    at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:111)
    at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
    at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:685)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:799)
    at org.kohsuke.stapler.MetaClass$12.dispatch(MetaClass.java:381)
    at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:685)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:799)
    at org.kohsuke.stapler.MetaClass$4.doDispatch(MetaClass.java:201)
    at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
    at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:685)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:799)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:587)
    at org.kohsuke.stapler.Stapler.service(Stapler.java:218)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:45)
    at winstone.ServletConfiguration.execute(ServletConfiguration.java:248)
    at winstone.RequestDispatcher.forward(RequestDispatcher.java:333)
    at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:376)
    at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:96)
    at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:88)
    at winstone.FilterConfiguration.execute(FilterConfiguration.java:194)
    at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:366)
    at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:48)
    at winstone.FilterConfiguration.execute(FilterConfiguration.java:194)
    at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:366)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
    at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
    at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:117)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
    at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
    at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:135)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
    at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
    at org.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(BasicProcessingFilter.java:174)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
    at jenkins.security.ApiTokenFilter.doFilter(ApiTokenFilter.java:64)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
    at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
    at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67)
    at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
    at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76)
    at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:164)
    at winstone.FilterConfiguration.execute(FilterConfiguration.java:194)
    at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:366)
    at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:46)
    at winstone.FilterConfiguration.execute(FilterConfiguration.java:194)
    at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:366)
    at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:81)
    at winstone.FilterConfiguration.execute(FilterConfiguration.java:194)
    at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:366)
    at winstone.RequestDispatcher.forward(RequestDispatcher.java:331)
    at winstone.RequestHandlerThread.processRequest(RequestHandlerThread.java:227)
    at winstone.RequestHandlerThread.run(RequestHandlerThread.java:150)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:679)
    Caused by: java.lang.NullPointerException
    at java.util.regex.Pattern.(Pattern.java:1149)
    at java.util.regex.Pattern.compile(Pattern.java:840)
    at java.util.regex.Pattern.matches(Pattern.java:945)
    at hudson.plugins.validating_string_parameter.ValidatingStringParameterDefinition$DescriptorImpl.doValidate(ValidatingStringParameterDefinition.java:126)
    ... 69 more

    1. I have discovered the same problem. As your post is almost 4 years old, I am guessing it is not going to ever get fixed. :/

  7. I had originally downloaded this plugin, some months ago, and things seemed to be working fine.

    And just recently I've noticed, last 2 weeks to a month ago, the validations don't seem to be happening.

    I've even upgraded to version 2.3, and it still doesn't seem to work correctly :(

    When I type values in the fields everything seems to be accepted/not validated.

    Works with any browser I user, IE and FF

    Whether I'm logged in or not.

    Seems to be happening with coworkers as well.

    Any suggestions ?

    Known conflicts with any other plugins ?

  8. This doesnt seem to be working anymore.. I used this at my last job just fine, and trying to use it again, but it doesnt work.

    I created a Validating String Param, and set the Regex pattern to* .+-SNAPSHOT* (exactly whats in the above examples), but when I click build, it executes the build, even if the value is empty

    1. If you look at the implementation of class ValidatingStringParameterValue you'll see that it overrides the implementation of public BuildWrapper createBuildWrapper(AbstractBuild<?, ?> build) in a way that aborts if the string is invalid. This will only work on Freestyle jobs and other job types extending AbstractBuild. I'm afraid this does not apply to pipeline jobs. Maybe in your prior project you used freestyle jobs.

  9. Hi Team,

     

    Can we look at an enchasement to disable the build button if the validation fails. Enable only when all the validations have passed. 

    Regards,

    Aditya