Reputation: 563
My Code snippet below,(running from Jenkins)
def mainUrl = "http://localhost:8080/job/"
...
jobsName.each(){
println "Jobs: ${it}"
println "${mainUrl}${it}/config.xml"
}
Which gives output like below:
Jobs: Env_test
Jobs: Dev_test
Jobs: Model test
Jobs: Prod test
I'm trying to replace the space character with % and used replaceAll method too, still no luck.
println "${mainUrl}${it}.replaceAll("//s","%")/config.xml"
Output I got:
http://localhost:8080/job/Model test.replaceAll(
http://localhost:8080/job/Prod test.replaceAll(
I'm looking for a Output like,
http://localhost:8080/job/Model%test/config.xml
http://localhost:8080/job/Prod%test/config.xml
Any suggestions . Thanks.
Upvotes: 2
Views: 1932
Reputation: 31011
Change your code to:
println "${mainUrl}${it}".replaceAll("\\s","%") + "/config.xml"
Taking this apart, it means:
mainUrl
and it
(you missed a double quote char after {it}
),/config.xml
, but as a separate string.Upvotes: 2