Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-10139

Using "\d+\.\d+\.\d+" as the regex does not work

    Details

    • Similar Issues:

      Description

      Ive realized that one of my previous mentioned problems with the plugin is that I used a regex that looks liks this \d+\.\d+\.\d+. Im using that regex to make sure that the person starting the build enters a proper version number, ie. 1.2.3

      Steps to reproduce

      1. Create a new job with the following configuration
        1. Build is parameterized
        2. Add a string validation
          1. Name = VALUE
          2. Regex = \d+\.\d+\.\d+
          3. Error = Enter a three digit version number
        3. Save the configuration
      2. Start a new build
      3. Enter 1.2.3 into the VALUE text box
      4. Move away focus from text box
      Expected outcome:

      The Enter a three digit version number text disappears and no error is shown

      Actual outcome:

      The Enter a three digit version number text is shown as an error

      If I use a .+ regex, then the error message disappears when I enter something into the textbox.

        Attachments

          Activity

          Hide
          kinwah kinwah lai added a comment -

          i have the same form validation problem but i resolve this by using \\d+\\.\\d+\\.
          d+.
          After that i have another problem, the plugin abort my build and show this error "ERROR: Invalid value for parameter [SOFTWARE_VERSION] specified: 2.11.0"
          i've no idea why it is an invalid value when it can pass the form validation.

          Show
          kinwah kinwah lai added a comment - i have the same form validation problem but i resolve this by using \\d+\\.\\d+\\. d+. After that i have another problem, the plugin abort my build and show this error "ERROR: Invalid value for parameter [SOFTWARE_VERSION] specified: 2.11.0" i've no idea why it is an invalid value when it can pass the form validation.
          Hide
          kinwah kinwah lai added a comment -

          the "\" in the "\d+\.\d+\.\d+" got removed when we use encodeURIComponent for checkUrl.

          Show
          kinwah kinwah lai added a comment - the "\" in the "\d+\.\d+\.\d+" got removed when we use encodeURIComponent for checkUrl.
          Hide
          rbxue rb xue added a comment - - edited

          Looks like in the web ui the "\" is removed and we need "\ \". While in build procedure it is not.
          As workaround, may be we can replace "\ \" to "\" for regex in ValidatingStringParameterValue.CreateBuildWrepper

          Show
          rbxue rb xue added a comment - - edited Looks like in the web ui the "\" is removed and we need "\ \". While in build procedure it is not. As workaround, may be we can replace "\ \" to "\" for regex in ValidatingStringParameterValue.CreateBuildWrepper
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Erik Ramfelt
          Path:
          src/main/java/hudson/plugins/validating_string_parameter/ValidatingStringParameterDefinition.java
          src/main/resources/hudson/plugins/validating_string_parameter/ValidatingStringParameterDefinition/index.jelly
          http://jenkins-ci.org/commit/validating-string-parameter-plugin/80a358fbc2eaff755116d32f83ee64fb5912721b
          Log:
          JENKINS-10139 Added method to return a java script encoded variant of the regex. Back slash is a special char and this will fix the problem with back slashes in regular expresions

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Erik Ramfelt Path: src/main/java/hudson/plugins/validating_string_parameter/ValidatingStringParameterDefinition.java src/main/resources/hudson/plugins/validating_string_parameter/ValidatingStringParameterDefinition/index.jelly http://jenkins-ci.org/commit/validating-string-parameter-plugin/80a358fbc2eaff755116d32f83ee64fb5912721b Log: JENKINS-10139 Added method to return a java script encoded variant of the regex. Back slash is a special char and this will fix the problem with back slashes in regular expresions
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Peter Hayes
          Path:
          src/main/java/hudson/plugins/validating_string_parameter/ValidatingStringParameterDefinition.java
          src/main/resources/hudson/plugins/validating_string_parameter/ValidatingStringParameterDefinition/index.jelly
          http://jenkins-ci.org/commit/validating-string-parameter-plugin/c48afbb1e5e9f64c80ac26d5d109033f82b02e89
          Log:
          Merge pull request #1 from redsolo/jenkins-10139

          JENKINS-10139 Fix for regex containing back slashes

          Compare: https://github.com/jenkinsci/validating-string-parameter-plugin/compare/b787ed0...c48afbb

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Peter Hayes Path: src/main/java/hudson/plugins/validating_string_parameter/ValidatingStringParameterDefinition.java src/main/resources/hudson/plugins/validating_string_parameter/ValidatingStringParameterDefinition/index.jelly http://jenkins-ci.org/commit/validating-string-parameter-plugin/c48afbb1e5e9f64c80ac26d5d109033f82b02e89 Log: Merge pull request #1 from redsolo/jenkins-10139 JENKINS-10139 Fix for regex containing back slashes Compare: https://github.com/jenkinsci/validating-string-parameter-plugin/compare/b787ed0...c48afbb
          Hide
          dogfood dogfood added a comment -

          Integrated in plugins_validating-string-parameter #18
          JENKINS-10139 Added method to return a java script encoded variant of the regex. Back slash is a special char and this will fix the problem with back slashes in regular expresions

          eramfelt :
          Files :

          • src/main/java/hudson/plugins/validating_string_parameter/ValidatingStringParameterDefinition.java
          • src/main/resources/hudson/plugins/validating_string_parameter/ValidatingStringParameterDefinition/index.jelly
          Show
          dogfood dogfood added a comment - Integrated in plugins_validating-string-parameter #18 JENKINS-10139 Added method to return a java script encoded variant of the regex. Back slash is a special char and this will fix the problem with back slashes in regular expresions eramfelt : Files : src/main/java/hudson/plugins/validating_string_parameter/ValidatingStringParameterDefinition.java src/main/resources/hudson/plugins/validating_string_parameter/ValidatingStringParameterDefinition/index.jelly
          Hide
          fredg Fred G added a comment -

          This issue seems to be fixed with validating-string-parameter plugin version 2.2.
          Please re-open, if the problem still exists.

          Show
          fredg Fred G added a comment - This issue seems to be fixed with validating-string-parameter plugin version 2.2. Please re-open, if the problem still exists.

            People

            • Assignee:
              petehayes Peter Hayes
              Reporter:
              redsolo redsolo
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: