-
Type:
Bug
-
Resolution: Not A Defect
-
Priority:
Major
-
Component/s: workflow-durable-task-step-plugin
-
Environment:MacOS 10.13.1
Jenkins 2.92
JDK 1.8 Oracle
Using this as a minimal example:
script {
def testString1 = "echo a="
def testString2 = "!123"
def testString3 = "b="
def testString4 = "2937"
print "testString1+2 = "+testString1+testString2
print "testString3+4 = "+testString3+testString4
print "total: "+testString1+testString2+testString3+testString4
sh "echo ${testString1}${testString2}"
sh "eval ${testString1}${testString2}"
sh "echo ${testString1}${testString2} ${testString3}${testString4}"
sh "eval ${testString1}${testString2} ${testString3}${testString4}"
}
The result while running the pipeline is:
[Pipeline] script
[Pipeline] {
[Pipeline] echo
testString1+2 = echo a=!123
[Pipeline] echo
testString3+4 = b=2937
[Pipeline] echo
total: echo a=!123b=2937
[Pipeline] sh
[pipeName] Running shell script
+ echo echo 'a=!123'
echo a=!123
[Pipeline] sh
[pipeName] Running shell script
+ eval echo 'a=!123'
++ echo 'a=!123'
a=!123
[Pipeline] sh
[pipeName] Running shell script
+ echo echo 'a=!123' b=2937
echo a=!123 b=2937
[Pipeline] sh
[pipeName] Running shell script
+ eval echo 'a=!123' b=2937
++ echo 'a=!123' b=2937
a=!123 b=2937
[Pipeline] }
[Pipeline] // script
Notice that last echo treats strings differently depending on whether or not the exclamation mark is contained within a contiguous string.
This creates issues when, for example, creating maven options dynamically at runtime. Trying to generate
-Dopt1=test -Dopt2=test!1
leads to a string
-Dopt1=test '-Dopt2=test!1'
which then doesn't work.
This treatment of strings lacking consistency, and despite all my efforts to try to trim the string (or create the string within a shell script, etc), ultimately this issue is a bottleneck.
Let me know if I am missing something, I will happily provide more information if needed.