9

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

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.

tk421
  • 5,775
  • 6
  • 23
  • 34
Umair Cheema
  • 403
  • 2
  • 6
  • 14

3 Answers3

10

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!

Mathew Bellamy
  • 113
  • 2
  • 10
1

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.

007
  • 161
  • 1
  • 3
  • 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
Ali Katkar
  • 517
  • 4
  • 7