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

append tool HOME to PATH in declarative Pipeline

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Component/s: customtools-plugin
    • Labels:
      None
    • Environment:
      custom-tools-plugin: 0.5
      Jenkins: 2.89.4.1
    • Similar Issues:

      Description

      I have the following custom-tool configured:

       

      Name: jx-release-version
      Install automatically: on
      Script:

      #!/bin/sh
      set -e
      
      JX_RELEASE_VERSION=v1.0.10
      JX_RELEASE_VERSION_DIR=${HOME}/tools/jx-release-version-${JX_RELEASE_VERSION}
      
      if test ! -x "${JX_RELEASE_VERSION_DIR}"/jx-release-version ; then
        mkdir -p "${JX_RELEASE_VERSION_DIR}"
        cd "${JX_RELEASE_VERSION_DIR}"
        wget https://github.com/jenkins-x/jx-release-version/releases/download/${JX_RELEASE_VERSION}/jx-release-version-linux
        mv jx-release-version-linux jx-release-version
        chmod 755 jx-release-version
      fi

      Tool Home: /${HOME}/tools/jx-release-version-v1.0.10

       

      And I try to use it in my pipeline, the tool gets installed, but its HOME is not added to PATH:

      pipeline {
        agent { label 'lxc-fedora25' }
        tools {
          'com.cloudbees.jenkins.plugins.customtools.CustomTool' 'jx-release-version'
        }
        stages {
          stage ('step 1') {
            steps {
              script {
                sh "jx-release-version"
              }
            }
          }
        }
      }

      If I do it this way, then it works all fine, but this is not really the declarative way to do it:

      pipeline {
        agent { label 'lxc-fedora25' }
        environment {
          jx_path = tool name: 'jx-release-version', type: 'com.cloudbees.jenkins.plugins.customtools.CustomTool'
        }
        stages {
          stage ('step 1') {
            steps {
              script {
                sh "${jx_path}/jx-release-version"
              }
            }
          }
        }
      }

      So my request is, to support the first pipeline definition and add the custom-tool HOME to PATH, which I'm sure is what people would expect this plugin todo.

       

        Attachments

          Activity

          Hide
          imod Dominik Bartholdi added a comment -

          Andrew Bayer just a little ping about this issue, as we discussed a couple of weeks ago...

          Show
          imod Dominik Bartholdi added a comment - Andrew Bayer just a little ping about this issue, as we discussed a couple of weeks ago...
          Hide
          oleg_nenashev Oleg Nenashev added a comment -

          No plan to work on this feature, I have marked the plugin for adoption.

          Dominik Bartholdi is it a Jenkins X-related feature request just in case?

          Show
          oleg_nenashev Oleg Nenashev added a comment - No plan to work on this feature, I have marked the plugin for adoption. Dominik Bartholdi is it a Jenkins X-related feature request just in case?
          Hide
          imod Dominik Bartholdi added a comment -

          Oleg Nenashev no, its not related to Jenkins X - it just happens that we use a Tool provided by Jenkins X in a standalone way

          Show
          imod Dominik Bartholdi added a comment - Oleg Nenashev no, its not related to Jenkins X - it just happens that we use a Tool provided by Jenkins X in a standalone way
          Hide
          auge Benjamin St. added a comment - - edited

          I usually add it manually:

            environment {
              jx_path = tool name: 'jx-release-version', type: 'com.cloudbees.jenkins.plugins.customtools.CustomTool'
              PATH = "${jx_path}:${PATH}"
          //    PATH = "${jx_path};${PATH}" // on windows, you need ;
            }
          

          then the tool is also first in path

          Show
          auge Benjamin St. added a comment - - edited I usually add it manually: environment { jx_path = tool name: 'jx-release-version' , type: 'com.cloudbees.jenkins.plugins.customtools.CustomTool' PATH = "${jx_path}:${PATH}" // PATH = "${jx_path};${PATH}" // on windows, you need ; } then the tool is also first in path

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            imod Dominik Bartholdi
            Votes:
            3 Vote for this issue
            Watchers:
            8 Start watching this issue

              Dates

              Created:
              Updated: