I set up my jenkins job to take in the parameter payload
and set its value to test\ntest
.
My jenkins script is the following:
def hardset = "test\ntest"
echo "param:"
def cleanParam = jenkinsParam.replaceAll("[\\n\\t ]","Yes");
echo cleanParam
echo "----------"
echo "hardset:"
def cleanHardset = hardset.replaceAll("[\\n\\t ]","Yes");
echo cleanHardset
The output is (cleaned up to remove jenkins pipeline echos):
test\ntest
param:
test\ntest
----------
hardset:
testYestest
Why? What's different between reading in a jenkins parameter and setting one in the script body?
In practice, I'm trying to replace troublesome \n
coming in from a lambda payload, but this is throwing a wrench in my plans.
doing something like def hardsetParam = jenkinsParam
to set it in the script body doesn't seem to work either, sadly.
In response to a comment - doing echo jenkinsParam
gives me test\ntest
. To my eyes, it's identical to hardset.
echo hardset
and see if the behaviour is similar to what I have just answered.