【发布时间】:2016-10-30 05:15:01
【问题描述】:
我需要一个帮助。
我正在使用 grunt 来编译 CSS/JS
我有一个问题,即每次构建都会创建我的节点包,并且它在 Jenkins 中占用了大量空间。我正在使用相同的 maven 前端插件。
我希望该节点包最初只创建一次,而不是在每个 maven 构建时再次创建。
<id>grunt</id>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>0.0.26</version>
<!-- optional -->
<configuration>
<workingDirectory>DIR
</workingDirectory>
<nodeVersion>v4.2.1</nodeVersion>
<npmVersion>3.5.1</npmVersion>
<installDirectory>node</installDirectory>
</configuration>
<executions>
<execution>
<id>node and npm install</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<arguments>install</arguments>
<installDirectory>node</installDirectory>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install</arguments>
<installDirectory>node</installDirectory>
</configuration>
</execution>
<execution>
<id>grunt build</id>
<goals>
<goal>grunt</goal>
</goals>
<configuration>
<arguments>build</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
我们正在使用 maven -P grunt 进行构建。它正在为每个 Maven 构建创建和安装节点。
为了在全球范围内拥有节点,我正在尝试 maven -P grunt -g ,但它不起作用。
在 GitHub 群里,我看到有人说我们不能用 maven frontend plugin 做,所以我尝试了 maven exec plugin。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>prepare-dist-npm-runtime-dependency</id>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>node/node</executable>
<workingDirectory>dist</workingDirectory>
<arguments>
<argument>../node/npm/cli.js</argument>
<argument>install</argument>
<argument>--production</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
但我无法看到它工作。谁能帮助如何运行 maven 以使其适用于全局节点安装而不是在每次构建时安装节点?
如果有任何其他建议只安装一次节点而不是全局安装将不胜感激。
【问题讨论】:
-
我认为因为你一直使用配置文件运行 maven build,它会在你构建的时候生成节点。我认为您应该配置您的 jenkins CI 仅在脚本发生某些更改时触发构建。默认情况下,jenkins 应该运行默认的 maven 构建,而不是通过配置文件运行。