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

Custom tools plugin is not compatiable with new pipeline plugin

      I am running Jenkins 2. I am trying to build from a Jenkinsfile

      The existing custom tools plugin is not compatiable with pipeline

      https://github.com/jenkinsci/pipeline-plugin/blob/master/COMPATIBILITY.md

      https://github.com/jenkinsci/pipeline-plugin/blob/master/TUTORIAL.md

      https://github.com/tonymurphy/sbt-pipeline

      from freenode
      tony_murphy: fixing Custom Tools plugin looks feasible, though not trivial: https://github.com/jenkinsci/pipeline-plugin/blob/master/DEVGUIDE.md

      #build-wrappers would need to make the `LauncherDecorator` be safely `Serializable`

      #!groovy
      
      node {
      
          wrap([$class: 'AnsiColorBuildWrapper', colorMapName: 'xterm']) {
              stage 'compile'
      
              def activatorHome  = tool "activator-1.3.x"
      
              stage name: 'package', concurrency: 1
              sh "${activatorHome}/activator debian:package-bin"
          }
      }
      

          [JENKINS-37413] Custom tools plugin is not compatiable with new pipeline plugin

          Oleg Nenashev added a comment -

          Generally duplicates JENKINS-30680

          Oleg Nenashev added a comment - Generally duplicates JENKINS-30680

          Tony Murphy added a comment - - edited

          I installed the activator tool and as as workaround to the issues of running activator from the workspace job folder, I did the following

          I did have to allow access to environment variables via http://jenkins-server:8080/scriptApproval/

          #!groovy
          
          node {
          
              wrap([$class: 'AnsiColorBuildWrapper', colorMapName: 'xterm']) {
                  stage 'build'
                  withEnv(["PATH+ACTIVATOR=${tool 'activator-1.3.x'}"]) {
                          sh "cd ${env.JENKINS_HOME}/workspace/${env.JOB_NAME}@script && activator debian:package-bin"
                  }
              }
          }
          

          This doesn't work on docker based agents

          Tony Murphy added a comment - - edited I installed the activator tool and as as workaround to the issues of running activator from the workspace job folder, I did the following I did have to allow access to environment variables via http://jenkins-server:8080/scriptApproval/ #!groovy node { wrap([$class: 'AnsiColorBuildWrapper' , colorMapName: 'xterm' ]) { stage 'build' withEnv([ "PATH+ACTIVATOR=${tool 'activator-1.3.x' }" ]) { sh "cd ${env.JENKINS_HOME}/workspace/${env.JOB_NAME}@script && activator debian: package -bin" } } } This doesn't work on docker based agents

          Tony Murphy added a comment -

          Turns out my problems were more related to confusion with how multi branch pipelines in Jenkins 2 work. Custom tool is working ok for me once I worked around those Issues

          Tony Murphy added a comment - Turns out my problems were more related to confusion with how multi branch pipelines in Jenkins 2 work. Custom tool is working ok for me once I worked around those Issues

          James Howe added a comment -

          For declarative pipelines this also works, but does not set environment variables:

          tools {
            com.cloudbees.jenkins.plugins.customtools.CustomTool 'Tool Name'
          }
          

          However, this does not work:

          environment {
            TOOL_HOME="${tool 'Tool Name'}"
          }
          

          James Howe added a comment - For declarative pipelines this also works, but does not set environment variables: tools { com.cloudbees.jenkins.plugins.customtools.CustomTool 'Tool Name' } However, this does not work: environment { TOOL_HOME= "${tool 'Tool Name' }" }

            oleg_nenashev Oleg Nenashev
            tony_murphy Tony Murphy
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: