I understand that the basic format is something like echo | sed '../../..'
I've been accessing the Jenkins params variable as such:
sh label: '', script: ' echo "${params}" | sed \'s/\\([[:alnum:]_][[:alnum:]_]*\\)/"\\1"/g\''
the "sh label" and "script" elements are from the pipeline syntax snippet generator that Jenkins provides.
Yet as an output the echo just outputs a blank line, and if I echo separately after the statement, the params variable is unchanged.
I know my regex is working perfectly as I've tested it directly on multiple strings.
I figure my error lies somewhere with how I'm accessing the reserved Jenkins params object, and that sed isn't accessing it as a string, rather an object (?).
I also assumed that maybe the params object wasn't saving the sed edits, so I tried storing it like so:
def params = sh (script: ' echo $params | sed \'s/\\([[:alnum:]_][[:alnum:]_]*\\)/"\\1"/g\'', , returnStdout:true).trim()
Could someone please help, or move me in the right direction? Thanks.