<p>Use the Groovy <code>trim()</code> method.  For instance, <code>def myTrimmedParam = params.myParam.trim()</code>.</p>

CC BY-SA 4.0
2019-06-19T17:54:14.300Z
2019-06-19T17:54:14.300Z
jayhendren
<p>You can use the trim parameter:</p>
<pre><code>string(name: 'some parameter', trim: true)
</code></pre>

CC BY-SA 4.0
2021-03-26T09:47:09.050Z
from which version can you use trim? I did not find it in the documentation https://www.jenkins.io/doc/book/pipeline/syntax/#parameters
Miguel Costa
CC BY-SA 4.0
2021-03-26T10:15:35.803Z
I just tried it on my jenkins indeed it works, very nice
Miguel Costa
CC BY-SA 4.0
2020-06-30T21:02:29.190Z
2020-06-30T21:02:29.190Z
Jay Prall
<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>

CC BY-SA 4.0
2019-06-18T13:20:08.963Z
why is your job failing ?
Rsf
CC BY-SA 4.0
2019-06-19T03:12:05.017Z
When i leave some spaces in parameter value its getting failed.
Naik
CC BY-SA 4.0
2019-06-19T03:13:42.850Z
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
Naik
<jenkins><jenkins-pipeline>
How to trim spaces for parameter value in jenkins pipeline?
Naik
# 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  

---

