【发布时间】:2018-04-08 01:28:47
【问题描述】:
当我尝试自动安装和构建 Angular 2 应用程序时出现以下错误。该应用程序在 GIT 上,那部分很好。我达到了第二个目标,我可以很好地安装 nodeModules,但是在试图将 angular 应用程序构建到 dist 文件夹的第二步中它失败了。我基本上希望它在 maven 中执行相当于 ng build --environment=sys 的操作。
[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?
【问题讨论】:
-
我会重新考虑使用 Maven 来构建 Angular 应用程序...
-
您认为哪种方式效果更好?
-
用
ng build...怎么样? -
感谢 khmarbaise,npm build 是前进的方向,请参阅下文
-
我不会将 Maven 用于此类应用程序...仅
ng build......
标签: angular maven jenkins build pom.xml