2014-03-06 159 views
1

你好,我嘗試在詹金斯執行工作的NodeJS:詹金斯的NodeJS-插件

Jenkins integration with Grunt

但我無法連接到registry.npmjs.org/拋詹金斯。 我設置詹金斯代理的插件 - >高級,但我得到STIL此錯誤:

Started by user anonymous 
Building in workspace /var/lib/jenkins/jobs/TempDemo/workspace 
$ /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/recent_node_0.11.11_/bin/npm install -g [email protected]~0.1.0 
npm http GET https://registry.npmjs.org/grunt-cli 
npm http GET https://registry.npmjs.org/grunt-cli 
npm http GET https://registry.npmjs.org/grunt-cli 
npm ERR! Error: connect ECONNREFUSED 
npm ERR!  at exports._errnoException (util.js:682:11) 
npm ERR!  at Object.afterConnect [as oncomplete] (net.js:947:19) 
npm ERR! { [Error: connect ECONNREFUSED] 
npm ERR! stack: 'Error: connect ECONNREFUSED\n at exports._errnoException (util.js:682:11)\n at Object.afterConnect [as oncomplete] (net.js:947:19)', 
npm ERR! code: 'ECONNREFUSED', 
npm ERR! errno: 'ECONNREFUSED', 
npm ERR! syscall: 'connect' } 
npm ERR! 
npm ERR! If you are behind a proxy, please make sure that the 
npm ERR! 'proxy' config is set properly. See: 'npm help config' 

我應該怎麼辦?

回答

1

我只有一個權宜之計,因爲我找不到任何有關配置插件與代理一起使用的信息。我創建了一個npm可執行文件的包裝器,它在調用底層npm腳本之前設置了代理器的詳細信息。步驟:

  1. 設置NodeJS安裝,啓動一個使用它並獲取失敗的作業(如上所述)。這應該在/ tools中留下一個Node安裝文件夾。我看到你是「/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/recent_node_0.11.11_」。

  2. 導航到此位置的/ bin文件夾。

  3. 重命名故宮可執行鏈接: 「MV NPM NPM-實際」

  4. 創建一個新的NPM文件:touch NPM

  5. 設置內容如下:

    \#!/bin/sh 
    
    /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/recent_node_0.11.11_/bin/npm-actual config set proxy "<proxy url with optional credentials>" 
    
    /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/recent_node_0.11.11_/bin/npm-actual config set https-proxy "<proxy url with optional credentials>" 
    
    /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/recent_node_0.11.11_/bin/npm-actual "[email protected]" 
    
  6. 確保這個新的npm腳本屬於Jenkins用戶,並且它被標記爲可執行文件。

重新運行Jenkins作業,它應該使用上面的代理設置並能夠下載它所需的內容。這些設置模仿那些在〜/ .npmrc和更多信息發現可以在這裏找到:

http://jjasonclark.com/how-to-setup-node-behind-web-proxy

希望有所幫助。如果有人有更好,更正確的解決方案,我很樂意聽到它。

1

您可以設置NPM爲使用代理,則可能需要須藤

npm config set proxy http://yourproxy.com:80