2015-08-28 30 views
4

我們有一個公司代理,它阻止我按照原樣使用maven-frontend-plugin。如何將nodejs和npm可執行文件上傳到artifactory

問題是,要獲取npm和bower依賴關係,我們使用內部Artifactory,所以我們不應該有任何代理設置。但是實際的可執行文件被直接提取以獲取它們,我們需要代理。前端插件似乎不支持特定域的例外情況。

那麼是否有一種簡單的方法將npm和nodejs可執行文件上傳到我們的內部工件,以便我們可以完全跳過這個代理?或者解決此問題的另一種方法?

編輯

我在這裏添加解決方案以方便,因爲我需要修改我在下面批准了答案。

在Artifactory中設置兩個遠程存儲庫,一個存儲到nodejs(https://nodejs.org/dist/),另一個存儲到npm(https://registry.npmjs.org/npm/-/)。

編輯您的Maven的前端 - 插件配置:

<execution> 
    <!-- optional: you don't really need execution ids, 
    but it looks nice in your build log. --> 
    <id>install node and npm</id> 
    <goals> 
     <goal>install-node-and-npm</goal> 
    </goals> 
    <!-- optional: default phase is "generate-resources" --> 
    <phase>generate-resources</phase> 
    <configuration> 
     <nodeVersion>v0.12.1</nodeVersion> 
     <npmVersion>2.14.1</npmVersion> 
     <!-- use the URL for the repository you created in step 1 --> 
     <nodeDownloadRoot>https://artifactory.my company.com/artifactory/nodejs.dist/</nodeDownloadRoot> 
     <npmDownloadRoot>https://artifactory.my company.com/artifactory/npm.dist/</npmDownloadRoot> 
    </configuration> 
</execution> 

這是可能的僅僅使用正回購的NodeJS(但當時故宮僅適用於1.4.9版本)更改npmDownloadRoot到:

<npmDownloadRoot>https://artifactory.my company.com/artifactory/nodejs.dist/npm/</npmDownloadRoot>

而且不要忘記從你的Maven刪除代理服務器設置settings.xml

回答

5

若要從Artifactory的節點和NPM可執行文件,你應該:

  1. 創建Artifactory的新倉庫將被用於節點和NPM分佈。如果您使用的是Artifactory 4.x,則應該創建一個遠程generic repository(對於舊版本,只需創建一個遠程存儲庫)。
    該庫應代理的節點和故宮分發服務器 - https://nodejs.org/dist/
    另一種選擇是創建一個本地資源庫和手動部署節點和故宮分佈進去,同時保持相同的佈局https://nodejs.org/dist/
  2. 配置前端,Maven的插件使用Artifactory而不是默認值。這應該通過設置downloadRoot屬性,例如做:
<execution> 
    <!-- optional: you don't really need execution ids, 
    but it looks nice in your build log. --> 
    <id>install node and npm</id> 
    <goals> 
     <goal>install-node-and-npm</goal> 
    </goals> 
    <!-- optional: default phase is "generate-resources" --> 
    <phase>generate-resources</phase> 
    <configuration> 
     <nodeVersion>v0.10.18</nodeVersion> 
     <npmVersion>1.3.8</npmVersion> 
     <!-- use the URL for the repository you created in step 1 --> 
     <downloadRoot>http://localhost:8081/artifactory/repo-id/</downloadRoot> 
    </configuration> 
</execution> 

欲瞭解更多信息插件文件

+0

好極了,應該是這麼簡單,剩下的唯一煩人的事情就是獲得更新版本的npm(看起來像nodejs dist repo只有版本1.4.9)。你不會知道這個網址嗎?谷歌搜索給了我噸無關緊要的命中。 – osundblad

+0

找到它'https://registry.npmjs.org/npm/ - /'結尾的' - /'很重要 – osundblad

0

使用Artifactory代理npm註冊表並託管您自己的npms和可執行文件是一個很好的決定,您的管理員表現良好。

對於從UI部署任何文件到Artifactory,您可以使用Deploy選項卡(Artifactory 3)或工件瀏覽器(Artifactory 4)中的Deploy按鈕。

另一個選項(可能是更可取的)將使用npm publishUser Guide給出了非常詳細的說明如何做到這一點。如果您使用Artifactory的4,您也可以點擊陷害我按鈕,在神器瀏覽器屏幕: Artifactory Set Me Up - how to deploy npm package

第三種選擇,這適用於任何文件,將a simple PUT HTTP request

+0

對不起,我不清楚問題在看到installing node and npm。我們還沒有Artifactory中的可執行文件。問題實際上是否有一種簡單的方法將可執行文件上傳到它(Artifactory)。我碰巧是它的管理員,而且我無法找到任何有關如何讓它們及其在Artifactory中發佈的依賴關係的信息。 – osundblad

+0

我的答案是關於如何將工件部署到Artifactory。 – JBaruch

相關問題