2017-10-26 5 views
1

Angle 2アプリケーションのインストールとビルドを自動化しようとしているときに、以下のエラーが表示されます。アプリケーションはGITにあり、その部分は問題ありません。私は2番目の目標に到達するまで、nodeModulesをうまくインストールできますが、角度アプリケーションをdistフォルダに構築しようとしている2番目のステップで失敗します。基本的には、mavenでng build --environment = sysと同等の処理をしたいと考えています。JenkinsビルドエラーMaven Angular2

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:exec (ng build) on project consumer-dashboard: Command execution failed. Cannot run program "ng" (in directory "D:\Jenkins\PFS Jobs\consumer-dashboard\workspace\consumer-dashboard\src"): CreateProcess error=2, The system cannot find the file specified -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[JENKINS] Archiving D:\Jenkins\PFS Jobs\consumer-dashboard\workspace\consumer-dashboard\pom.xml to consumer-dashboard/consumer-dashboard/1.0.0-SNAPSHOT/consumer-dashboard-1.0.0-SNAPSHOT.pom 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException 
channel stopped 

Jenkinsを使用してビルドサーバーでpomで実行します。

<build> 
<plugins> 
<plugin> 
    <artifactId>exec-maven-plugin</artifactId> 
    <groupId>org.codehaus.mojo</groupId> 
    <version>1.4.0</version> 
    <executions> 
    <execution> 
     <id>npm install</id> 
     <goals> 
     <goal>exec</goal> 
     </goals> 
     <phase>generate-sources</phase> 
     <configuration> 
     <executable>npm</executable> 
     <arguments> 
      <argument>install</argument> 
      <argument>-g angular-cli</argument> 
     </arguments> 
     <workingDirectory>./src</workingDirectory> 
     <target> 
      <echo message="npm install" /> 
     </target> 
     </configuration> 
    </execution> 
    <execution> 
     <id>ng build</id> 
     <goals> 
     <goal>exec</goal> 
     </goals> 
     <phase>generate-sources</phase> 
     <configuration> 
     <executable>ng</executable> 
     <arguments> 
      <argument>build</argument> 
      <argument>--environment=sys</argument> 
     </arguments> 
     <workingDirectory>./src</workingDirectory> 
     <target> 
      <echo message="ng build" /> 
     </target> 
     </configuration> 
    </execution> 
    </executions> 
</plugin> 
</plugins> 
</build> 

なぜngが見つかりませんか。

+0

角度アプリを構築するためにMavenを使用することを再考したいと思います... – khmarbaise

+0

もっとうまくいくと思いますか? –

+0

'ng build ...'を使うのはどうですか? – khmarbaise

答えて

0

私はこれを次のように解決しました。

 <plugin> 
      <artifactId>exec-maven-plugin</artifactId> 
      <groupId>org.codehaus.mojo</groupId> 
      <version>1.4.0</version> 
      <executions> 
      <execution> 
       <id>npm install</id> 
       <goals> 
       <goal>exec</goal> 
       </goals> 
       <phase>generate-sources</phase> 
       <configuration> 
       <executable>npm</executable> 
       <arguments> 
        <argument>install</argument> 
       </arguments> 
       <workingDirectory>./</workingDirectory> 
       <target> 
        <echo message="npm install" /> 
       </target> 
       </configuration> 
      </execution> 
      <execution> 
       <id>ng build</id> 
       <goals> 
       <goal>exec</goal> 
       </goals> 
       <phase>generate-sources</phase> 
       <configuration> 
       <executable>npm</executable> 
       <arguments> 
        <argument>run</argument> 
        <argument>build-sys</argument> 
       </arguments> 
       <workingDirectory>./</workingDirectory> 
       <target> 
        <echo message="ng build" /> 
       </target> 
       </configuration> 
      </execution> 
      </executions> 
     </plugin> 

「build-sys」を追加しています。

{ 
    "name": "project-name", 
    "version": "0.0.0", 
    "license": "MIT", 
    "scripts": { 
    "ng": "ng", 
    "start": "ng serve", 
    "build": "ng build", 
    "build-sys": "ng build --environment=sys", 
    "test": "ng test", 
    "lint": "ng lint", 
    "e2e": "ng e2e" 
    } 

これを行うことで、正しい環境プロパティを含むdistが完成しました。

アドバイスのために@khmarbaiseに感謝します!

関連する問題