Details

    • Similar Issues:

      Description

      Rather than

      withEnv(["PATH=${tool 'Maven 3.2.2'}/bin:${env.PATH}"]) {sh 'mvn package'}
      

      you should be able to say

      withTool('Maven 3.2.2') {sh 'mvn package'}
      

      where this code builds the environment variables within the block.

        Attachments

          Issue Links

            Activity

            Hide
            abayer Andrew Bayer added a comment -

            Agreed. There's real value in tool just installing the tool - in case you've got multiple versions of a tool used in the same workflow/node.

            Show
            abayer Andrew Bayer added a comment - Agreed. There's real value in tool just installing the tool - in case you've got multiple versions of a tool used in the same workflow/node.
            Hide
            aheritier Arnaud Héritier added a comment -

            +1 for all of this but you cannot always automatically install a tool. Have a look at Oracle JDK where you need credentials and validate the terms & conditions ...
            Thus requiring that some tools are pre-installed/configured on Jenkins side will be probably always a need and in that case I would like to have the availability control as soon as possible ....

            Show
            aheritier Arnaud Héritier added a comment - +1 for all of this but you cannot always automatically install a tool. Have a look at Oracle JDK where you need credentials and validate the terms & conditions ... Thus requiring that some tools are pre-installed/configured on Jenkins side will be probably always a need and in that case I would like to have the availability control as soon as possible ....
            Hide
            mikedougherty Mike Dougherty added a comment -

            I've implemented a `withTool` function that we're using at Docker. It's available to our Jenkins instances via the workflow-cps-global-lib-plugin. You can see the implementation here: https://github.com/docker/jenkins-pipeline-scripts/blob/master/vars/withTool.groovy

            I'm sure it's not perfect, but it works well so far.

            Show
            mikedougherty Mike Dougherty added a comment - I've implemented a `withTool` function that we're using at Docker. It's available to our Jenkins instances via the workflow-cps-global-lib-plugin. You can see the implementation here: https://github.com/docker/jenkins-pipeline-scripts/blob/master/vars/withTool.groovy I'm sure it's not perfect, but it works well so far.
            Hide
            abayer Andrew Bayer added a comment -

            Ooo, nifty stuff - wanna write a blog post about your shared stuff? =)

            Show
            abayer Andrew Bayer added a comment - Ooo, nifty stuff - wanna write a blog post about your shared stuff? =)
            Hide
            jglick Jesse Glick added a comment -

            EnvVarsForToolStep seems to do this for Declarative.

            Show
            jglick Jesse Glick added a comment - EnvVarsForToolStep seems to do this for Declarative.

              People

              • Assignee:
                jglick Jesse Glick
                Reporter:
                jglick Jesse Glick
              • Votes:
                8 Vote for this issue
                Watchers:
                17 Start watching this issue

                Dates

                • Created:
                  Updated: