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

append tool HOME to PATH in declarative Pipeline

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • customtools-plugin
    • None
    • custom-tools-plugin: 0.5
      Jenkins: 2.89.4.1

      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.

       

            Unassigned Unassigned
            imod Dominik Bartholdi
            Votes:
            3 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: