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?
-
why is your job failing ?– RsfCommented Jun 18, 2019 at 13:20
-
When i leave some spaces in parameter value its getting failed.– NaikCommented Jun 19, 2019 at 3:12
-
1ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.– NaikCommented Jun 19, 2019 at 3:13
Add a comment
|
2 Answers
Use the Groovy trim()
method. For instance, def myTrimmedParam = params.myParam.trim()
.
You can use the trim parameter:
string(name: 'some parameter', trim: true)
-
from which version can you use trim? I did not find it in the documentation jenkins.io/doc/book/pipeline/syntax/#parameters Commented Mar 26, 2021 at 9:47
-
1I just tried it on my jenkins indeed it works, very nice Commented Mar 26, 2021 at 10:15