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

Custom tools plugin is not compatiable with new pipeline plugin

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      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"
          }
      }
      

        Attachments

          Issue Links

            Activity

            Hide
            oleg_nenashev Oleg Nenashev added a comment -

            Generally duplicates JENKINS-30680

            Show
            oleg_nenashev Oleg Nenashev added a comment - Generally duplicates JENKINS-30680
            Hide
            tony_murphy 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

            Show
            tony_murphy 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
            Hide
            tony_murphy 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

            Show
            tony_murphy 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
            Hide
            jameshowe 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'}"
            }
            
            Show
            jameshowe 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' }" }

              People

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

                Dates

                Created:
                Updated:
                Resolved: