我的jenkins盒子上安装了node,npm和grunt。我能够在Jenkins的预备步骤中使用execute shell成功运行以下命令。
PATH=$PATH:/sev/installed/node-v0.10.31/bin
rm -rf node_modules
rm -rf bower_components
npm install --python=/sev/installed/Python-2.7.3/bin/python
npm update --python=/sev/installed/Python-2.7.3/bin/python
bower install
bower update
当我调用mvn clean包时,下一步,Build失败并显示错误
./usr/bin/env: node: No such file or directory
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.973s
[INFO] Finished at: Tue Aug 26 23:51:16 GMT+00:00 2014
[INFO] Final Memory: 17M/438M
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default) on project TestUI: Command execution failed. Process exited with an error: 127 (Exit value: 127) -> [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.
我在这个Linux机器上没有root访问权限。 Maven exec插件,正在构建失败。插件定义在pom下面。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
<phase>prepare-package</phase>
</execution>
</executions>
<configuration>
<executable>${project.basedir}/node_modules/grunt-cli/bin/grunt</executable>
<workingDirectory>${project.basedir}</workingDirectory>
</configuration>
</plugin
我无法通过符号链接将节点安装指向/ usr / bin。有什么方法可以解决这个问题吗?
答案 0 :(得分:2)
我在尝试使用exec-maven-plugin
时遇到了很多问题。根据我的经验,frontend-maven-plugin
远远不是这种类型的构建/部署过程的最佳插件。它将在本地下载/安装Node和NPM,运行NPM安装,Grunt,Gulp和/或Karma。由于我的构建服务器在构建期间到达网络外部时有非常严格的限制,因此我提交了服务器版本的节点以及我使用的任何节点包和grunt。
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>...</version>
<!-- optional -->
<configuration>
<workingDirectory>src/main/frontend</workingDirectory>
</configuration>
<execution>
<id>grunt build</id>
<goals>
<goal>grunt</goal>
</goals>
<!-- optional: the default phase is "generate-resources" -->
<phase>generate-resources</phase>
<configuration>
<!-- optional: if not specified, it will run Grunt's default
task (and you can remove this whole <configuration> section.) -->
<arguments>build</arguments>
</configuration>
</execution>
</plugin>
有一点需要注意的是它将为正在运行的系统下载节点,因此如果您的构建服务器上有不同的操作系统,则需要确保这是您已签入的版本版本控制,您的本地版本(对我来说OSX)必须在您的项目本地维护。有关在此StackOverflow线程上使用frontend-maven-plugin
和Grunt的讨论:“ Is it possible to compile grunt project from maven? ”