-
Bug
-
Resolution: Fixed
-
Minor
-
Pipeline: Model Definition 1.1.4
I have a parameter called JDK_TOOL and would like to use the parameter inside of my declarative pipeline tools definition but this script does not work:
pipeline { agent any tools { jdk "${params.JDK_TOOL}" } stages { stage('Example') { steps { sh 'jdk --version' } } } }
I get an error which says:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: WorkflowScript: 7: Tool type "jdk" does not have an install of ""${params.JDK_TOOL}"" configured - did you mean "TEST2"? @ line 7, column 5. jdk "${params.JDK_TOOL}"
so it does not seem to actually parse the variable at all(and adds the " as well)
- links to
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.