Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-44497

Tools should allow variables in their names for declarative pipeline

    Details

    • Epic Link:
    • Similar Issues:

      Description

      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)

        Attachments

          Issue Links

            Activity

            ataylor Alex Taylor created issue -
            abayer Andrew Bayer made changes -
            Field Original Value New Value
            Labels declarative-variable-and-method-resolution
            abayer Andrew Bayer made changes -
            Epic Link JENKINS-45422 [ 183590 ]
            abayer Andrew Bayer made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            abayer Andrew Bayer made changes -
            Status In Progress [ 3 ] In Review [ 10005 ]
            abayer Andrew Bayer made changes -
            Remote Link This issue links to "PR #190 (Web Link)" [ 17616 ]
            abayer Andrew Bayer made changes -
            Status In Review [ 10005 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                ataylor Alex Taylor
              • Votes:
                2 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: