Given the following Pipeline:
pipeline {
agent any
parameters {
string(name: 'mvnTool', defaultValue: 'apache-maven-3.0.1', description: '' )
}
tools {
maven "${params.mvnTool}"
}
stages {
stage('Example') {
steps {
sh 'mvn --version'
}
}
}
}
This will result in an unknown tool error.
If you remove the quotes and try it as
Then the Declarative parser will prepend "${ and append }" around the variable and you get the same error. It recognizes it as a variable enough to wrap it in a variable quote but does not expand it.
I tried many various combinations of string escaping to use a variable here with no luck.
The same is true of environment variables or trying to use the groovy variable directly without the 'params.' object.
Given the following Pipeline:
This will result in an unknown tool error.
If you remove the quotes and try it as
Then the Declarative parser will prepend "${ and append }" around the variable and you get the same error. It recognizes it as a variable enough to wrap it in a variable quote but does not expand it.
I tried many various combinations of string escaping to use a variable here with no luck.
The same is true of environment variables or trying to use the groovy variable directly without the 'params.' object.