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

With pipeline, tools does not setup properly the environment

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • nodejs-plugin
    • None
    • Running latest version of Jenkins on Docker, with all nodejs (4 to 7) installed in my Dockerfile. Using latest ndejs-plugin version.

      Hi,

      The `tools{nodejs 'xxx'}` and `tool name: 'xxx'` do not select the appropriate nodejs when there is several installations of nodejs.
      I made a full description on stackoverflow: http://stackoverflow.com/questions/42261382/jenkins-pipeline-select-nodejs-version-python-version

       

      Cheers,

      Olivier

          [JENKINS-43066] With pipeline, tools does not setup properly the environment

          I'm facing the same issue with the standard Jenkins jobs. NodeJS is not added to the path while checking "Provide Node & npm bin/ folder to PATH"

          Sébastien Bro added a comment - I'm facing the same issue with the standard Jenkins jobs. NodeJS is not added to the path while checking "Provide Node & npm bin/ folder to PATH"

          Nikolas Falco added a comment -

          Please report also the version of plugin in the issue.

          This sound like duplicate of one of these JENKINS-27170 JENKINS-41762 JENKINS-42323 JENKINS-41857 JENKINS-43066

          Do you have EnvInject plugin installed?
          If yes than you fall in JENKINS-26583

          Workaround is remove EnvInject plugin, or make a custom build of workaround-26583 branch. (this branch will never merge into master, it's a EnvInject plugin issue not nodejs)

          Nikolas Falco added a comment - Please report also the version of plugin in the issue. This sound like duplicate of one of these JENKINS-27170 JENKINS-41762 JENKINS-42323 JENKINS-41857 JENKINS-43066 Do you have EnvInject plugin installed? If yes than you fall in JENKINS-26583 Workaround is remove EnvInject plugin, or make a custom build of workaround-26583 branch. (this branch will never merge into master, it's a EnvInject plugin issue not nodejs)

          Nikolas Falco added a comment -

          I've try the pipeline script you post at stackoverflow on our jenkins installation and it works.
          Follow the expected output:

          [Pipeline] node
          
          Running on master in /var/lib/jenkins/jobs/test/workspace
          [Pipeline] {
          [Pipeline] stage
          [Pipeline] { (Declarative: Tool Install)
          [Pipeline] tool
          $ /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node_6.x/bin/npm install -g webpack webpack-dev-server phantomjs
          
          npm WARN deprecated phantomjs@2.1.7: Package renamed to phantomjs-prebuilt. Please update 'phantomjs' package references to 'phantomjs-prebuilt'
          ...CUTTED
          [Pipeline] envVarsForTool
          
          [Pipeline] }
          [Pipeline] // stage
          [Pipeline] withEnv
          [Pipeline] {
          [Pipeline] stage
          [Pipeline] { (Example)
          [Pipeline] sh
          [workspace] Running shell script
          + npm --version
          3.10.3
          [Pipeline] }
          [Pipeline] // stage
          [Pipeline] }
          [Pipeline] // withEnv
          [Pipeline] }
          [Pipeline] // node
          
          [Pipeline] End of Pipeline
          Finished: SUCCESS
          

          In the case of JENKINS-26583 and you do not want build plugin yourself or you do not want uninstall EnvInject Plugin than the correct way (the same suggested for jdk tool as reported by cloudbees) should be:

          node {
              env.NODE_HOME="${tool 'Node 6.x'}"
              env.PATH="${env.NODE_HOME}/bin:${env.PATH}"
              sh 'npm -version'
          }
          

          Nikolas Falco added a comment - I've try the pipeline script you post at stackoverflow on our jenkins installation and it works. Follow the expected output: [Pipeline] node Running on master in /var/lib/jenkins/jobs/test/workspace [Pipeline] { [Pipeline] stage [Pipeline] { (Declarative: Tool Install) [Pipeline] tool $ /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/Node_6.x/bin/npm install -g webpack webpack-dev-server phantomjs npm WARN deprecated phantomjs@2.1.7: Package renamed to phantomjs-prebuilt. Please update 'phantomjs' package references to 'phantomjs-prebuilt' ...CUTTED [Pipeline] envVarsForTool [Pipeline] } [Pipeline] // stage [Pipeline] withEnv [Pipeline] { [Pipeline] stage [Pipeline] { (Example) [Pipeline] sh [workspace] Running shell script + npm --version 3.10.3 [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline Finished: SUCCESS In the case of JENKINS-26583 and you do not want build plugin yourself or you do not want uninstall EnvInject Plugin than the correct way (the same suggested for jdk tool as reported by cloudbees ) should be: node { env.NODE_HOME= "${tool 'Node 6.x' }" env.PATH= "${env.NODE_HOME}/bin:${env.PATH}" sh 'npm -version' }

            Unassigned Unassigned
            dupreolivier Olivier Dupré
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: