【问题标题】:Jenkins Build Error: Build step 'Invoke top-level Maven targets' marked build as failureJenkins 构建错误:构建步骤“调用顶级 Maven 目标”将构建标记为失败
【发布时间】:2017-07-12 05:16:21
【问题描述】:

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>

我将非常感谢您对此提供的任何帮助。 谢谢。

【问题讨论】:

    标签: jenkins build maven-3 yarnpkg


    【解决方案1】:

    Jenkins 中的某些 maven 版本似乎存在问题, 另一个合适的解决方案是在 Jenkins 上添加另一个 maven 安装。

    1. 从 Jenkins 的起始页转到:管理 Jenkins > 全局工具 配置,然后向下滚动查找 Maven 部分。
    2. 按下“Maven 安装”按钮并配置一个新的 Maven 安装。 see the image "Maven installation button"

    3. 在名为“名称”的文本框中键入您要识别的名称 那个新安装。例如。 “Apache Maven 3.3.9”。

    4. 选中“自动安装”选项。
    5. 在选择菜单中选择版本 3.3.9。 see the image "New maven installation"

    6. 点击下方的保存按钮。

    7. 进入 Jenkins 主页并输入您要构建的作业。
    8. 在左侧,单击“配置”选项。
    9. 然后在构建部分中选择您已经设置的新 maven 安装的名称。 see image "set the new maven installation"
    10. 点击保存并重新构建您的工作。

    如果您看到构建 #? 的输出控制台,Jenkins 将下载新的 maven 版本并将其安装在您的机器上并执行构建。

    如果一切正常,您应该会看到:[INFO] BUILD SUCCESS...

    这将帮助您了解该版本的 maven 是否可以正常工作。然后你可以在你的系统上安装第二个 maven 版本。

    在您的机器上安装其他 maven 版本后,重新配置它:
    管理 Jenkins > Global Tool Configuration 并设置 maven 源 (src) 文件夹的路径,但这次取消选中“自动安装选项”see image "Set maven path installation" 现在您可以在 Jenkins 中构建所有作业。

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

    祝你好运!

    【讨论】:

    • 这个问题的最佳答案。耐心描述所有步骤。谢谢,马特?
    【解决方案2】:

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

    1. 从运行环境中卸载你的 maven。

    2. 安装 Maven 表单:

      wgethttp://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. 文件末尾添加以下行并保存文件。

      导出 M2_HOME=/opt/apache-maven-3.3.9/

      导出 M2="$M2_HOME"bin

      导出 PATH=$PATH:$M2

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

    7. 您的 Maven 主路径已设置。你可以使用echo $M2_HOME 命令查看。

    8. 运行您的项目。

    【讨论】:

      【解决方案3】:
      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
      

      【讨论】:

        猜你喜欢
        • 2017-03-18
        • 2019-11-25
        • 2016-02-21
        • 2016-01-26
        • 2017-10-09
        • 2017-06-19
        • 2020-05-12
        • 1970-01-01
        • 2019-12-01
        相关资源
        最近更新 更多