allegro / grunt-maven-plugin

Grunt + Maven integration done right
Other
213 stars 32 forks source link

Running grunt-maven-plugin on Jenkins. Can't execute "grunt" in target-grunt, does not exist #56

Closed dbclkclk closed 9 years ago

dbclkclk commented 10 years ago

Hey Folks:

I am getting the following issue from Jenkins. Any ideas?

 [ERROR] Failed to execute goal pl.allegro:grunt-maven-plugin:1.4.1:bower (default) on project xxxxxx-frontend: Unable to execute mojo: Command execution failed. Cannot run program "bower" (in directory "/home/rof/src/bitbucket.org/jorge-sandoval/xxxxx_web/target-grunt"): error=2, No such file or directory -> [Help 1]
 org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal pl.allegro:grunt-maven-plugin:1.4.1:bower (default) on project xxxxxx-frontend: Unable to execute mojo
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
   Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to execute mojo
at org.twdata.maven.mojoexecutor.MojoExecutor.executeMojoImpl(MojoExecutor.java:174)
at org.twdata.maven.mojoexecutor.MojoExecutor$ExecutionEnvironmentM3.executeMojo(MojoExecutor.java:476)
at org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo(MojoExecutor.java:75)
at pl.allegro.tdr.gruntmaven.AbstractExecutableMojo.runExecutable(AbstractExecutableMojo.java:97)
at pl.allegro.tdr.gruntmaven.AbstractExecutableMojo.executeInternal(AbstractExecutableMojo.java:86)
at pl.allegro.tdr.gruntmaven.BaseMavenGruntMojo.execute(BaseMavenGruntMojo.java:93)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
   Caused by: org.apache.maven.plugin.MojoExecutionException: Command execution failed.
at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:367)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.twdata.maven.mojoexecutor.MojoExecutor.executeMojoImpl(MojoExecutor.java:172)
... 26 more
  Caused by: java.io.IOException: Cannot run program "bower" (in directory "/home/rof/src/bitbucket.org/jorge-sandoval/xxxxx_web/target-grunt"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)
at java.lang.Runtime.exec(Runtime.java:617)
at org.apache.commons.exec.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58)
at org.apache.commons.exec.DefaultExecutor.launch(DefaultExecutor.java:254)
at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:319)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:610)
at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:352)
... 28 more
   Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:186)
at java.lang.ProcessImpl.start(ProcessImpl.java:130)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1028)
... 35 more
   [ERROR] 
   [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/confluence/display/MAVEN/MojoExecutionException
     ]0;rof@railsonfire_49cb3d50-5633-0132-ec5d-0ea20a292b56_55927d21849c:      ~/clonerof@railsonfire_49cb3d50-5633-0132-ec5d-0ea20a292b56_55927d21849c:~/clone$ 
adamdubiel commented 10 years ago

Hm, can you show me your configuration from pom.xml? Looks like it might be some bower arguments problem.

dbclkclk commented 10 years ago

Thanks @adamdubiel

  <build>
    <finalName>xxxxx-website</finalName>
    <plugins>
        <plugin>
            <artifactId>maven-eclipse-plugin</artifactId>
            <version>2.9</version>
            <configuration>
                <additionalProjectnatures>
                    <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                </additionalProjectnatures>
                <additionalBuildcommands>
                        <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                </additionalBuildcommands>
                <downloadSources>true</downloadSources>
                <downloadJavadocs>true</downloadJavadocs>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
             <version>3.0</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <compilerArgument>-Xlint:all</compilerArgument>
                <showWarnings>true</showWarnings>
                <showDeprecation>true</showDeprecation>

            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <warSourceExcludes>/resources/js/**</warSourceExcludes>
            </configuration>
        </plugin>
        <plugin>
            <groupId>pl.allegro</groupId>
            <artifactId>grunt-maven-plugin</artifactId>
            <version>1.4.1</version>
            <configuration>
                <!-- relative to src/main/webapp/, default: static -->
                <jsSourceDirectory>/resources/js/</jsSourceDirectory>

                <!-- example options usage to get verbose output in logs -->
                <gruntOptions>
                    <gruntOption>--verbose</gruntOption>
                </gruntOptions>

                <!-- example npm install env variable -->
                <npmEnvironmentVar>
                    <PHANTOMJS_CDNURL>http://cnpmjs.org/downloads</PHANTOMJS_CDNURL>
                </npmEnvironmentVar>

                <!-- example options usage to filter variables in given resource -->
                <filteredResources>
                    <filteredResource>maven-properties.json</filteredResource>
                </filteredResources>
            </configuration>
            <executions>
                <execution>
                    <goals>
                           <goal>create-resources</goal>
                        <goal>npm</goal>
                        <!-- or npm-offline if npm failure is not an option -->
                        <goal>bower</goal>
                        <goal>grunt</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.16</version>
            <dependencies>
                <dependency>
                    <groupId>org.apache.maven.surefire</groupId>
                    <artifactId>surefire-junit47</artifactId>
                    <version>2.12</version>
                </dependency>
            </dependencies>
            <executions>

                <execution>
                     <id>unit-tests</id>
                      <phase>unit-test</phase>
                      <goals>
                         <goal>test</goal>
                      </goals>
                      <configuration>
                            <testFailureIgnore>false</testFailureIgnore>
                            <includes>
                                <include>**/*UnitTest.java</include>
                            </includes>
                        </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.18</version>
                <configuration>
                <includes>
                    <include>**/*IntegrationTest.java</include>
                </includes>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
        </plugin>
    </plugins>
</build>
adamdubiel commented 10 years ago

Hm, okay, so it's just standard config - something with environment then. Could you disable bower target and see if grunt builds? Do you have bower as system-wide executable on Jenkins?

dbclkclk commented 10 years ago

Do you mean removing "bower" from the goal? I did and the build fails for another goal "grunt". See error

  Cannot run program "grunt" (in directory "/home/rof/src/bitbucket.org/jorge-sandoval/xxxxx_web/target-grunt"): error=2, No such file or directory -> [Help 1

I am beginning to think this has something to do with exec. it keeps complaining that the directory does not exist. The build is being run on Jenkins not locally. Locall with maven test, everything passes.

adamdubiel commented 10 years ago

I think it's something with environment. Do you have grunt-cli installed on Jenkins? I don't see any other explaination for this exit code. Alternatively, try running grunt like this.

dbclkclk commented 10 years ago

@adamdubiel That could be the issue. I don't have the grunt-cli in the dependency. I will try it out. Thanks.

conmute commented 8 years ago

In case if somone as me faced similar issue, please not that

sudo npm install -g grunt is not the same as npm install -g grunt if yuo are using such tools as nave, nvm or n for node version management.

shrzmk commented 7 years ago

Hey, Even I am facing the same issue on Jenkins build when I try maven deploy command. In local eclipse everything works fine. I have only these below entries in pom.xml.

Can anyone help me resolve this?

<plugin>
<groupId>pl.allegro</groupId>
      <artifactId>grunt-maven-plugin</artifactId>
      <version>1.4.1</version>
      <executions>
        <execution>
          <goals>
            <goal>npm</goal>
            <goal>grunt</goal>
          </goals>
        </execution>
      </executions>
    </plugin>

And this is my GruntFile

module.exports = function(grunt) {
    grunt.loadNpmTasks('grunt-contrib-uglify');
  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    uglify: {
        core: {
            files: [{
              expand: true,
              cwd: 'src/main/webapp',
              src: 'js/*.js',
              dest: "src/main/webapp/build",
              ext: '.min.js'
            }]
        }
    },
  });

  grunt.registerTask('default', ['uglify']);

};