Jenkins构建错误:构建步骤“调用顶层Maven目标”将构建标记为失败。

9

Jenkins构建失败,出现以下错误:

构建步骤“调用顶级Maven目标”将构建标记为失败

我是Jenkins的新手,不确定为什么构建失败。请查看日志:

[INFO] yarn install v0.27.5
[INFO] [1/4] Resolving packages...
[INFO] [2/4] Fetching packages...
[WARNING] warning fsevents@1.1.1: The platform "linux" is incompatible with this module.
[INFO] info "fsevents@1.1.1" is an optional dependency and failed compatibility check. Excluding it from installation.
[INFO] [3/4] Linking dependencies...
[INFO] [4/4] Building fresh packages...
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE

我的pom.xml配置如下:

<properties>
        <project.frontend.nodeVersion>v6.10.0</project.frontend.nodeVersion>
        <project.frontend.yarnVersion>v0.27.5</project.frontend.yarnVersion>
        <skipGulp>false</skipGulp>
        <build.args>publish:dev:all</build.args>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>1.3</version>
                <configuration>
                    <skip>${skipGulp}</skip>
                </configuration>
                <executions>
                    <execution>
                        <id>install node and yarn</id>
                        <goals>
                            <goal>install-node-and-yarn</goal>
                        </goals>
                        <configuration>
                            <nodeVersion>${project.frontend.nodeVersion}</nodeVersion>
                            <yarnVersion>${project.frontend.yarnVersion}</yarnVersion>
                        </configuration>
                    </execution>
                    <execution>
                        <id>yarn install</id>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
            <configuration>
              <failOnError>false</failOnError>
            </configuration>
                    </execution>
          <execution>
            <id>fix node-sass package</id>
            <goals>
              <goal>npm</goal>
            </goals>
            <configuration>
              <arguments>rebuild node-sass</arguments>
            </configuration>
          </execution>
                    <execution>
                        <id>yarn</id>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>run ${build.args}</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

我非常感谢你能帮忙处理这个问题。 谢谢。

3个回答

10
似乎Jenkins中的某些Maven版本存在问题,另一种适当的解决方案是在Jenkins上添加另一个Maven安装实例。请按照以下步骤操作:
  1. 从Jenkins的起始页进入:Manage Jenkins > Global Tool Configuration,向下滚动查找Maven部分。
  2. 点击"Maven Installations"按钮配置一个新的Maven安装实例。 查看"Maven installation button"图片

  3. 在名为"Name"的文本框中输入您想要标识这个新安装实例的名称,例如:"Apache Maven 3.3.9"。

  4. 勾选"Install automatically"选项。
  5. 在下拉菜单中选择版本3.3.9。 查看"New maven installation"图片

  6. 最后点击保存按钮。

  7. 回到Jenkins首页并进入您想要构建的任务。
  8. 在左侧点击"Configure"选项。
  9. 然后在构建部分选择您已经设置的新Maven安装实例的名称。查看 "set the new maven installation" 图片
  10. 点击保存并重新构建任务。

如果您查看构建#?的输出控制台,Jenkins会下载新的Maven版本并在您的机器上安装和执行构建。

如果一切正常,您应该会看到" [INFO] BUILD SUCCESS..."。
这将帮助您了解该Maven版本是否运行良好。然后,您可以在系统上安装第二个Maven版本。

一旦您在计算机上安装了另一个Maven版本,请在以下位置重新配置它:
管理 Jenkins > 全局工具配置,设置 Maven 源(src)文件夹的路径,但这次取消“自动安装”选项查看图片“设置 maven 路径安装”,现在您可以在 Jenkins 中构建所有作业。

最后,重复“第7、8和9步”以将新配置设置为默认配置!

祝好运!


请耐心地描述所有步骤,给出最佳答案。谢谢,马特。 - jsina

1

按照以下步骤解决问题。这对我有用。

  1. 从运行环境中卸载您的Maven。

  2. 安装Maven:

    wget http://www-eu.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz

  3. 使用以下命令解压tar文件:

    tar -zxvf apache-maven-3.3.9-bin.tar.gz

  4. 现在在环境中设置M2_HOME。打开vi /etc/profile

  5. 在文件末尾添加以下行并保存文件。

    export M2_HOME=/opt/apache-maven-3.3.9/

    export M2="$M2_HOME"bin

    export PATH=$PATH:$M2

  6. 使用source /etc/profile编译此文件。

  7. 您的Maven主目录已设置。您可以使用echo $M2_HOME命令进行检查。

  8. 运行您的项目。


0
I think the problem is not related with maven. The problem is the path
"C:\Program Files (x86)\Jenkins\workspace\" can not be resolved by Jenkins due to spaces. 
So workspace must be moved somewhere like "D:\DevTools\Jenkins\workspace".

My solution:

 1. create an environment variable like JENKINS_HOME = D:\DevTools\Jenkins\
 2. change C:\Program Files (x86)\Jenkins\jenkins.xml like below 
    <env name="JENKINS_HOME" value="%JENKINS_HOME%"/>
 3. restart Jenkins from web browser
    http://localhost:8080/restart

 4. Jenkins will be installed again, 
    Some running files will be stayed in "C:\Program Files (x86)\Jenkins".
    Only workspace and related files will be moved to new place
Now you can use Jenkins

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接