In one of the stages in a Jenkins pipeline, I need to pass the values from parameters to a script. Sometimes these values may contain a single quote sign which disrupts the run and doesn't come through to the script.
sh "pwsh -file script.ps1 '${params.NAME}' '${params.DESCRIPTION}' '${params.SOMETHING}'"
Ie when the script is called in the stage, the passed parameters may look like this:
'Name' 'Somebody's description' 'Something'
As you can see it messes with the arguments being passed on. It produces the error of an unterminated quoted string. I need to pass only 3 args to the script as the params suggest.
Any ways to solve this? Should I add another stage before calling the script that formats the values of the params in a way that is acceptable to pass to the PowerShell script? If so, how should I format it? Is there any other way to solve it?