Answers: <p>Use the Groovy <code>trim()</code> method.  For instance, <code>def myTrimmedParam = params.myParam.trim()</code>.</p>
  
Answers: CC BY-SA 4.0
Answers: 2019-06-19T17:54:14.300Z
Answers: 2019-06-19T17:54:14.300Z
Answers: jayhendren
Answers: <p>You can use the trim parameter:</p>
  <pre><code>string(name: 'some parameter', trim: true)
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2021-03-26T09:47:09.050Z
Answers: from which version can you use trim? I did not find it in the documentation https://www.jenkins.io/doc/book/pipeline/syntax/#parameters
Answers: Miguel Costa
Answers: CC BY-SA 4.0
Answers: 2021-03-26T10:15:35.803Z
Answers: I just tried it on my jenkins indeed it works, very nice
Answers: Miguel Costa
Answers: CC BY-SA 4.0
Answers: 2020-06-30T21:02:29.190Z
Answers: 2020-06-30T21:02:29.190Z
Answers: Jay Prall
Body: <p>I am using jenkins pipeline job with parameters. when i had any trailing spaces in parameter value the job gets failed. is there any way to trim the spaces in pipeline job to avoid build failure?</p>
  
Comments: CC BY-SA 4.0
Comments: 2019-06-18T13:20:08.963Z
Comments: why is your job failing ?
Comments: Rsf
Comments: CC BY-SA 4.0
Comments: 2019-06-19T03:12:05.017Z
Comments: When i leave some spaces in parameter value its getting failed.
Comments: Naik
Comments: CC BY-SA 4.0
Comments: 2019-06-19T03:13:42.850Z
Comments: ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Comments: Naik
Tags: <jenkins><jenkins-pipeline>
Title: How to trim spaces for parameter value in jenkins pipeline?
UserDisplayName: Naik
ThreadText: # How to trim spaces for parameter value in jenkins pipeline?
  
  (Asked by: username_0 on 2019-06-18)
  
  I am using jenkins pipeline job with parameters. when i had any trailing spaces in parameter value the job gets failed. is there any way to trim the spaces in pipeline job to avoid build failure?
  
  **Tags:** jenkins, jenkins-pipeline
  
  > **Comments:**
  > **username_1**: why is your job failing ?  
  > **username_0**: When i leave some spaces in parameter value its getting failed.  
  > **username_0**: ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2019-06-19. Score: 6
  
  Use the Groovy `trim()` method. For instance, `def myTrimmedParam = params.myParam.trim()`.
  
  
  ---
  
  ### Answer by username_3 on 2020-06-30. Score: 4
  
  You can use the trim parameter:
  
  ```
  string(name: 'some parameter', trim: true)
  
  ```
  
  > **Comments:**
  > **username_4**: from which version can you use trim? I did not find it in the documentation https://www.jenkins.io/doc/book/pipeline/syntax/#parameters  
  > **username_4**: I just tried it on my jenkins indeed it works, very nice  
  
  ---
  
  