I'm trying to use this maven command in a Jenkinsfile
mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec
I put this command in a variable in my jenkinsfile to use it later this way
def myCommand = 'mvn -q -Dexec.executable=echo -Dexec.args=\"${project.version}\" --non-recursive exec:exec'
...
def version = sh(${myCommand})
My problem is that Jenkins don't correctly escape my '${project.version}' and outputs java.lang.NoSuchMethodError: No such DSL method '$' found among steps
How do I correctly include '${project.version}' as a string in my command variable ?