-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
Jenkins 2.89.3
Pipeline 2.5
The below code works as expected as a standalone Groovy script (the if condition doesn't enter and so script value remains the same:
def script = '''mvn -q -Dexec.executable=echo -Dexec.args=\\${project.version} --non-recursive exec:exec''' def index if ((index = script.indexOf('release:prepare')) != -1) { script = script[0..<index-1] + ' -DpushChanges=false ' + script[index..-1] }
But the exact same code in a custom vars function misbehaves. The if condition enters anyway with an index value of -1 resulting in a script value of mvn -q -Dexec.executable=echo -Dexec.args=\${project.version} --non-recursive exec:ex -DpushChanges=false c
If I pull the assignment out of the if condition, it works as expected:
def index = script.indexOf('release:prepare') if (index != -1) {