Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Junit Cobertura给出的参数列表太长_Junit_Jenkins_Cobertura_Maven Cobertura Plugin - Fatal编程技术网

Junit Cobertura给出的参数列表太长

Junit Cobertura给出的参数列表太长,junit,jenkins,cobertura,maven-cobertura-plugin,Junit,Jenkins,Cobertura,Maven Cobertura Plugin,我正在尝试使用cobertura插件生成代码覆盖率报告 我在pom.xml中有这个依赖项 <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId> <version>2.6</version> <executions>

我正在尝试使用cobertura插件生成代码覆盖率报告

我在pom.xml中有这个依赖项

<plugin>
     <groupId>org.codehaus.mojo</groupId>
     <artifactId>cobertura-maven-plugin</artifactId>
     <version>2.6</version>
     <executions>
         <execution>
             <phase>test</phase>
             <goals>
              <goal>cobertura</goal>
             </goals>
             <configuration>
                 <formats>
                     <format>html</format>
                     <format>xml</format>
                  </formats>
             </configuration>
         </execution>
     </executions>
  <configuration>
      <formats>
          <format>html</format>
          <format>xml</format>
    </formats>
</configuration>

org.codehaus.mojo
cobertura maven插件
2.6
测试
科贝图拉
html
xml
html
xml

当我使用这个goal-U-B clean install cobertura:cobertura构建我的项目时,我在jenkins CI上得到以下错误

 16:37:31 [ERROR] Failed to execute goal org.codehaus.mojo:cobertura-maven-plugin:2.6:instrument (default-cli) on project TestModule: Unable to execute Cobertura. Error while executing process. Cannot run program "/bin/sh": error=7, Argument list too long -> [Help 1]
16:37:31 org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:cobertura-maven-plugin:2.6:instrument (default-cli) on project TestModule: Unable to execute Cobertura.
16:37:31    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
16:37:31    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
16:37:31    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
16:37:31    at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions(MojoExecutor.java:364)
16:37:31    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:198)
16:37:31    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
16:37:31    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
16:37:31    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
16:37:31    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
16:37:31    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
16:37:31    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
16:37:31    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
16:37:31    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
16:37:31    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
16:37:31    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
16:37:31    at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
16:37:31    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
16:37:31    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:76)
16:37:31    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
16:37:31    at java.lang.reflect.Method.invoke(Method.java:602)
16:37:31    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
16:37:31    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
16:37:31    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
16:37:31    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
16:37:31 Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to execute Cobertura.
16:37:31    at org.codehaus.mojo.cobertura.tasks.AbstractTask.executeJava(AbstractTask.java:244)
16:37:31    at org.codehaus.mojo.cobertura.tasks.InstrumentTask.execute(InstrumentTask.java:139)
16:37:31    at org.codehaus.mojo.cobertura.CoberturaInstrumentMojo.execute(CoberturaInstrumentMojo.java:162)
16:37:31    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
16:37:31    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
16:37:31    ... 23 more
16:37:31 Caused by: org.codehaus.plexus.util.cli.CommandLineException: Error while executing process.
16:37:31    at org.codehaus.plexus.util.cli.Commandline.execute(Commandline.java:656)
16:37:31    at org.codehaus.plexus.util.cli.CommandLineUtils.executeCommandLine(CommandLineUtils.java:144)
16:37:31    at org.codehaus.plexus.util.cli.CommandLineUtils.executeCommandLine(CommandLineUtils.java:107)
16:37:31    at org.codehaus.mojo.cobertura.tasks.AbstractTask.executeJava(AbstractTask.java:240)
16:37:31    ... 27 more
16:37:31 Caused by: java.io.IOException: Cannot run program "/bin/sh": error=7, Argument list too long
16:37:31    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1042)
16:37:31    at java.lang.Runtime.exec(Runtime.java:615)
16:37:31    at java.lang.Runtime.exec(Runtime.java:526)
16:37:31    at org.codehaus.plexus.util.cli.Commandline.execute(Commandline.java:636)
16:37:31    ... 30 more
16:37:31 Caused by: java.io.IOException: error=7, Argument list too long
16:37:31    at java.lang.UNIXProcess.<init>(UNIXProcess.java:139)
16:37:31    at java.lang.ProcessImpl.start(ProcessImpl.java:152)
16:37:31    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1023)
16:37:31    ... 33 more
16:37:31[错误]无法在项目TestModule上执行目标org.codehaus.mojo:cobertura maven插件:2.6:instrument(默认cli):无法执行cobertura。执行进程时出错。无法运行程序“/bin/sh”:错误=7,参数列表太长->[帮助1]
16:37:31 org.apache.maven.lifecycle.LifecycleeExecutionException:未能在项目测试模块上执行目标org.codehaus.mojo:cobertura maven插件:2.6:instrument(默认cli):无法执行cobertura。
16:37:31在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
16:37:31在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
16:37:31在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
16:37:31在org.apache.maven.lifecycle.internal.MojoExecutor.executeforkeredexecutions(MojoExecutor.java:364)
16:37:31在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:198)
16:37:31在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
16:37:31在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
16:37:31在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
16:37:31在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
16:37:31在org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
16:37:31在org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
16:37:31在org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
16:37:31在org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
16:37:31在org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
16:37:31在org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
16:37:31在org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
16:37:31在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)
16:37:31在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:76)
16:37:31在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
16:37:31位于java.lang.reflect.Method.invoke(Method.java:602)
16:37:31在org.codehaus.plexus.classworlds.launcher.launcher.launchEnhanced(launcher.java:289)
16:37:31在org.codehaus.plexus.classworlds.launcher.launcher.launch(launcher.java:229)
16:37:31在org.codehaus.plexus.classworlds.launcher.launcher.mainWithExitCode(launcher.java:415)
16:37:31在org.codehaus.plexus.classworlds.launcher.launcher.main(launcher.java:356)
16:37:31原因:org.apache.maven.plugin.MojoExecutionException:无法执行Cobertura。
16:37:31在org.codehaus.mojo.cobertura.tasks.AbstractTask.executeJava(AbstractTask.java:244)
16:37:31在org.codehaus.mojo.cobertura.tasks.InstrumentTask.execute(InstrumentTask.java:139)
16:37:31在org.codehaus.mojo.cobertura.coberturairmotionmojo.execute(coberturairmotionmojo.java:162)
16:37:31在org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
16:37:31在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
16:37:31    ... 23多
16:37:31原因:org.codehaus.plexus.util.cli.CommandLineException:执行进程时出错。
16:37:31在org.codehaus.plexus.util.cli.Commandline.execute(Commandline.java:656)
16:37:31在org.codehaus.plexus.util.cli.CommandLineUtils.executeCommandLine(CommandLineUtils.java:144)
16:37:31在org.codehaus.plexus.util.cli.CommandLineUtils.executeCommandLine(CommandLineUtils.java:107)
16:37:31在org.codehaus.mojo.cobertura.tasks.AbstractTask.executeJava(AbstractTask.java:240)
16:37:31    ... 还有27个
16:37:31原因:java.io.IOException:无法运行程序“/bin/sh”:错误=7,参数列表太长
16:37:31在java.lang.ProcessBuilder.start(ProcessBuilder.java:1042)
16:37:31在java.lang.Runtime.exec(Runtime.java:615)
16:37:31在java.lang.Runtime.exec(Runtime.java:526)
16:37:31在org.codehaus.plexus.util.cli.Commandline.execute(Commandline.java:636)
16:37:31    ... 30多
16:37:31原因:java.io.IOException:错误=7,参数列表太长
16:37:31在java.lang.UNIXProcess(UNIXProcess.java:139)
16:37:31在java.lang.ProcessImpl.start(ProcessImpl.java:152)
16:37:31在java.lang.ProcessBuilder.start(ProcessBuilder.java:1023)
16:37:31    ... 33多
构建在我的windows计算机上成功,但在jenkins上失败。当我将cobertura版本降级到2.5.1时,这个错误就消失了,但是我得到了一些解析异常,因为cobertura for 2.5.1的解析器并不是最新的java语法


有人能帮我在2.6.0版本和更高版本的cobertura中实现这一点吗

所有shell对命令行长度都有限制
UNIX
/
Linux
/
BSD
系统对命令行参数和环境变量可以使用的字节数有限制

启动新进程或键入命令时,将应用这些限制,您将在屏幕上看到如下错误消息:

参数列表太长

Cobertura正在尝试执行shell命令:getLog().debug( "Working Directory: " + cl.getWorkingDirectory() ); getLog().debug( "Executing command line:" ); getLog().debug( cl.toString() ); int exitCode; try { exitCode = CommandLineUtils.executeCommandLine( cl, stdout, stderr ); } catch ( CommandLineException e ) { throw new MojoExecutionException( "Unable to execute Cobertura.", e ); }
 Commandline cl = new Commandline();
 File java = new File( SystemUtils.getJavaHome(), "bin/java" );
 cl.setExecutable( java.getAbsolutePath() );
 cl.addEnvironment("CLASSPATH", createClasspath());

 String log4jConfig = getLog4jConfigFile();
 if ( log4jConfig != null )
 {
     cl.createArg().setValue( "-Dlog4j.configuration=" + log4jConfig );
 }

 cl.createArg().setValue( "-Xmx" + maxmem );

 cl.createArg().setValue( taskClass );

 if ( cmdLineArgs.useCommandsFile() )
 {
     String commandsFile;
     try
     {
          commandsFile = cmdLineArgs.getCommandsFile();
     }
     catch ( IOException e )
     {
           throw new MojoExecutionException( "Unable to obtain CommandsFile location.", e );
     }
     if ( FileUtils.fileExists( commandsFile ) ) 
     {
            cl.createArg().setValue( "--commandsfile" );
            cl.createArg().setValue( commandsFile );
      }
      else 
      {
             throw new MojoExecutionException( "CommandsFile doesn't exist: "  + commandsFile );
      }
 }
 else
 {
      Iterator<String> it = cmdLineArgs.iterator();
      while ( it.hasNext() )
      {
          cl.createArg().setValue( it.next() );
      }
 }