installing node on jenkins 2.0 using the pipeline plugin

前端 未结 3 880
挽巷
挽巷 2021-02-20 11:28

I am running the following docker image jenkinsci/jenkins:2.0-rc-1 to try out jenkins 2.0, and the \"pipeline\" view.

I can\'t seem to install node. Here\'s

相关标签:
3条回答
  • 2021-02-20 12:02

    For me work next code:

    node(){
      def nodeHome = tool 'nodejs5'
      env.PATH="${env.PATH}:${nodeHome}/bin"
      ...
      sh 'npm install'
    }
    

    nodejs5 is the name of the tool specified in Jenkins configuration.

    0 讨论(0)
  • 2021-02-20 12:12

    Either

    node {
      withEnv(["PATH+NODE=${tool name: 'node-5.10.1', type: 'jenkins.plugins.nodejs.tools.NodeJSInstallation'}/bin"]) {
        sh 'node -v'
      }
    }
    

    or

    node {
      def nodeHome = tool name: 'node-5.10.1', type: 'jenkins.plugins.nodejs.tools.NodeJSInstallation'
      sh "${nodeHome}/bin/node -v"
    }
    

    should work. See JENKINS-28718 for further proposals.

    By the way you can omit the type parameter and just use

    tool 'node-5.10.1'
    

    for brevity.

    0 讨论(0)
  • 2021-02-20 12:16

    If anyone happens to deal with this issue on Jenkins running on Windows. Do the following:

    def nodeHome = tool 'Node.js 6.9.5'
    bat "\"${nodeHome}\"\\node.exe -v"
    bat "\"${nodeHome}\"\\npm -v"
    
    0 讨论(0)
提交回复
热议问题