I have a Jenkins pipeline job. The job is taking an input parameter as string. I am able to retrieve that value from the script.
I wanted to add or enclose that string within double quotes. How can I achieve that?
Input parameter : www.google.com
In the script : echo InputLink
is printing me the value www.google.com
Expected result "www.google.com"
In your pipeline code just add quotes to the input string.
Assuming your input parameter is called Input:
quoted_input = '"' + Input + '"'
//or using string interpolation
quoted_input = "\"${Input}\""
Then you can use the quoted_input
wherever you need the quoted value.
If you are using a declarative pipeline use a script block:
script {
quoted_input = "\"${params.Input}\""
}
Or define it as an environment variable so it will be available for all stages:
pipeline {
environment {
QUOTED_INPUT = "\"${params.Input}\""
}
...
}