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?
Asked
Active
Viewed 1.7k times
6
-
why is your job failing ? – Rsf Jun 18 '19 at 13:20
-
When i leave some spaces in parameter value its getting failed. – Naik Jun 19 '19 at 03:12
-
1ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job. – Naik Jun 19 '19 at 03:13
2 Answers
6
Use the Groovy trim() method. For instance, def myTrimmedParam = params.myParam.trim().
jayhendren
- 2,952
- 7
- 15
4
You can use the trim parameter:
string(name: 'some parameter', trim: true)
Jay Prall
- 143
- 3
-
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 Mar 26 '21 at 09:47
-
1