Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Build Error: Build step 'Invoke top-level Maven targets' marked build as failure

Jenkins build is failing with

Build step 'Invoke top-level Maven targets' marked build as failure

I am new to Jenkins and not sure why build is failing. Please see the log:

[INFO] yarn install v0.27.5
[INFO] [1/4] Resolving packages...
[INFO] [2/4] Fetching packages...
[WARNING] warning [email protected]: The platform "linux" is incompatible with this module.
[INFO] info "[email protected]" 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

My pom.xml has below configurations:

<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>

I will really appreciate any help on this. Thanks.

like image 221
Umair Cheema Avatar asked Jul 12 '17 05:07

Umair Cheema


People also ask

How do I fix Jenkins build failure?

In Jenkins, in the pipeline where the failure occurred, in the navigation pane, click Rebuild. In the Rebuild page, select the ReRun check box , and click Rebuild.

What is compilation error in Jenkins?

Your error occurs due to lack of major settings in the jenkins-project, Jenkins don't know where find compiler.

What is Maven goal in Jenkins?

That is the goal of the Maven plugin for Jenkins. The central feature of the Maven plugin for Jenkins is the Maven 2/3 project type. Thanks to the Maven project object model (POM), this project type can automatically provide the following features: Archive artifacts produced by a build.


2 Answers

It seems there is a problem with some maven versions in Jenkins, Another suitable solution is to add another maven installation on Jenkins.

  1. From your start page in Jenkins go to: Manage Jenkins > Global Tool Configuration, and look for Maven section scrolling down.
  2. Press the button "Maven Installations" and config a new maven installation. see the image "Maven installation button"

  3. In the text box called "Name" Type the name you want to identify that new installation. eg. "Apache Maven 3.3.9".

  4. Check the option "Install automatically".
  5. In the select menu choose the version 3.3.9. see the image "New maven installation"

  6. Below hit the save button.

  7. Go to the Jenkins home page and enter the job you want to build.
  8. On the left side, click on the "Configure" option.
  9. Then in the Build Section choose the name of your new maven installation you have already set. see image "set the new maven installation"
  10. Hit save and re-buil your job.

if you see the output console of your build #?, Jenkins will download the new maven version and install it on your machine and execute the build as well.

If all is fine you should see: [INFO] BUILD SUCCESS...

This will help you to know if that version of maven works fine. Then you can install a second maven version on your system.

Once you have it installed the other maven version on your machine, re-config it on:
Manage Jenkins > Global Tool Configuration and set the path of the maven source (src) folder, but this time uncheck the "install automatically option" see image "Set maven path installation" now you can build all your jobs in Jenkins.

Finally repeat steps "7, 8 and 9" to set your new config as the default!

good luck!

like image 155
Mathew Bellamy Avatar answered Oct 15 '22 12:10

Mathew Bellamy


Follow below steps to solve problem. Its work for me.

  1. Uninstall you maven from running environment.

  2. Install Maven form :

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

  3. Extract tar file using:

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

  4. Now set M2_HOME in environment. Open vi /etc/profile

  5. End of file add below lines and save file.

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

    export M2="$M2_HOME"bin

    export PATH=$PATH:$M2

  6. Compile this file using source /etc/profile

  7. Your Maven home path is set. Yo can check using echo $M2_HOME command.

  8. Run your project.

like image 31
007 Avatar answered Oct 15 '22 13:10

007