2016-05-18 2 views
0

私はNodeJSのバージョンを管理するためにNVMを使用しています。私はJenkinsの仕事でそれをMavenと統合しようとしています。次のスクリプトは、Mavenが動作する前に実行されます。オプション引数としてNodeJSインストールディレクトリをMavenに渡す方法はないと思います。私はnvm useがNodeJSインストールディレクトリをPATHにエクスポートすると信じていますが、間違っている可能性があります。Mavenによるノードのバージョン管理戦略

#!/bin/sh -e 
source /mounts/dev/jenkins/.nvm/nvm.sh 
nvm alias default node 
nvm use --delete-prefix v4.2.0 --silent 

MavenのはNodeJSがあるため、デフォルトでは、NodeJSのグローバルインストールされたバージョンを使用して、yeoman-maven-plugin、である必要が理由。 JenkinsのNodeJSプラグインが機能していることは知っていますが、それを使うのは最適ではないと思います。

私はNVMをJenkins Mavenジョブに統合することは可能だと思いますが、私は間違った方法でそれをやっているかもしれません。誰かが別のNVMのアプローチに関するアイデアを持っていますか?

答えて

0

NVMとMavenを統合しようとするのではなく、yeoman-maven-pluginを放棄して、代わりにfrontend-maven-pluginとしました。 frontend-maven-pluginでは、GulpやGruntのような他のビルドツールとともに、ローカルのノードとNPMのインストールが可能です。行わなければならない唯一の変更はpom.xmlです。さらに、Jenkinsでの追加スクリプティングの必要はありません。プラグインの詳細については、hereを見つけることができるノードおよびNPM

<plugin> 
    ... 
    <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> 
    </execution> 
    <configuration> 
     <nodeVersion>v0.10.18</nodeVersion> 
     <npmVersion>1.3.8</npmVersion> 
     <!-- optional: where to download node and npm from. Defaults to https://nodejs.org/dist/ --> 
     <downloadRoot>http://myproxy.example.org/nodejs/dist/</downloadRoot> 
     <!-- optional: where to install node and npm. Defaults to the working directory --> 
     <installDirectory>target</installDirectory> 
    </configuration> 
</plugin> 

をインストールするため

使用例。

関連する問題