首页 > 解决方案 > 使用 Github Action CI/CD 时构建失败

问题描述

我正在使用 CI CD Github Action 进行构建,但我的构建在 github 上的分支失败。这是我遇到的错误:

Error:  Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.11.2:npm (npm run build) on project demo: Failed to run task: 'npm run build' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [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:
Error:  [Help 1] http://cwiki.apache.org/.../MAVEN/MojoFailureException
Error: Process completed with exit code 1.

我尝试在本地运行 npm run build ,它工作得很好。

标签: spring-bootgithubnpmcicd

解决方案


进入你的 pom.xml 文件,如果你的代码是这样的

             <plugin>
                    <groupId>com.github.eirslett</groupId>
                    <artifactId>frontend-maven-plugin</artifactId> 
                        ...

                        <execution>
                            <id>npm audit fix</id>
                            <goals>
                                <goal>npm</goal>
                            </goals>

                            <configuration>
                            <arguments>install</arguments>
                            </configuration>
                        </execution>

                       ...
             </plugin>

删除<configuration>...</configuration>部分,并更改为喜欢这个

             <plugin>
                    <groupId>com.github.eirslett</groupId>
                    <artifactId>frontend-maven-plugin</artifactId> 
                        ...

                        <execution>
                            <id>npm audit fix</id>
                            <goals>
                                <goal>npm</goal>
                            </goals>
                        </execution>

                       ...
             </plugin>

在你所有的<execution>...</execution>. 我希望你的代码能正常工作。


推荐阅读