2

Let's say that we have a jenkins pipeline that at some point we execute a maven parameterized build:

sh "mvn clean install -DparameterType=${parameter}"

What if the parameter's value contained spaces? Eg the value was "test param".

When running on IDE, this of course works:

mvn clean install -DparameterType="test param"

But if we do sth similar inside the pipeline, like

sh "mvn clean install -DparameterType=\"${parameter}\""

or

sh "mvn clean install -DparameterType=""${parameter}""

it doesn't and the param is passed like

-DparameterType=test param

which is not good for maven. Any ideas please?

gandalf_the_cool
  • 659
  • 2
  • 9
  • 23

1 Answers1

0

You can try using:

 sh """
 mvn clean install -DparameterType=\"${parameter}\"
 """
Altaf
  • 2,838
  • 1
  • 16
  • 8