• Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • job-dsl-plugin
    • Jenkins ver. 2.73.1
      job-dsl-plugin 1.65

      There are often failures when users input string parameter with an extra space.
      This leads to build failures in many cases.

      It would be great to be able to trim string parameter from the beginning. So it can be safely used everywhere down in the pipeline:

      parameters {
              string(defaultValue: "", description: '', name: 'tag or commit', trim: true)
      }
      

          [JENKINS-47986] Pipeline: Add trim option to String Parameter

          Alexander Vorobiev added a comment - - edited

          trim option was implemented in core under JENKINS-47115 .

          Alexander Vorobiev added a comment - - edited trim option was implemented in core under JENKINS-47115 .

          This is supported by the Automatically Generated DSL:

          job(String name) {
            parameters {
              stringParam {
                name(String value)
                defaultValue(String value)
                description(String value)
                trim(boolean value)
              }
            }
          } 
          

          Daniel Spilker added a comment - This is supported by the Automatically Generated DSL : job( String name) { parameters { stringParam { name( String value) defaultValue( String value) description( String value) trim( boolean value) } } }

          Jeffrey McClain added a comment - - edited

          I know this is a really old post, but daspilker do you know if there is a way to declare a string parameter with the trim boolean in a single line rather than multiline? I can do a single line string parameter declaration without the trim boolean as shown in this example: https://jenkinsci.github.io/job-dsl-plugin/#path/pipelineJob-parameters-stringParam However adding the trim boolean to the single line does not seem to work, unless I simply have the syntax wrong.

          Jeffrey McClain added a comment - - edited I know this is a really old post, but daspilker do you know if there is a way to declare a string parameter with the trim boolean in a single line rather than multiline? I can do a single line string parameter declaration without the trim boolean as shown in this example: https://jenkinsci.github.io/job-dsl-plugin/#path/pipelineJob-parameters-stringParam However adding the trim boolean to the single line does not seem to work, unless I simply have the syntax wrong.

            daspilker Daniel Spilker
            vorobievalex Alexander Vorobiev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: