2015-04-08 30 views
7

Cobertura eklentisini kullanarak kod kapsamı raporları oluşturmaya çalışıyorum.Cobertura Bağımsız değişken listesini çok uzun verir

Ben

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

Ben U -B temiz bu hedefe kullanarak projemi inşa cobertura yüklediğinizde benim pom.xml'Bu bu bağımlılık: cobertura, benim jenkins aşağıda hatası alıyorum 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 

inşa benim pencere makinede başarılı ama jenkins üzerinde başarısız olur. Cobertura sürümü 2.5.1'e düşürdüğümde bu hata gider, ancak 2.5.1 için cobertura ayrıştırıcısı java sözdizimi ile güncel olmadığı için bazı ayrıştırma durumları alıyorum.

birisi komut satırı uzunluğu için bir limit var bana 2.6.0 sürümleri için bu çalışma almak yardımcı ve cobertura

+0

lütfen ayarlarla bir ekran görüntüsü ekleyin (hata denetimi ve kısalık için yorumlara göz Stripped)? – stanjer

+0

Hangi ayarlara ihtiyacınız var? Sorularda cobertura eklenti ayarlarını yapıştırdım. Bu ayarlarla yerel (windows machine) içinde, scope.xml dosyası oluşturur ancak jenkins içinde – user2973475

+0

başarısız olur. Lütfen, cevabımı okuyun ve hata ayıklama izlerini verin, böylece size yardımcı olabilirim – jfcorugedo

cevap

1

Tüm kabuk için daha yüksek olabilir. UNIX/Linux/BSD Sisteminde, komut satırı argümanı ve ortam değişkenleri için kaç bayt kullanılabileceği konusunda bir sınır vardır.

Eğer yeni bir süreç başlatmak veya bu sınırlamalar uygulanır bir komut yazın ve ekrandaki şöyle bir hata mesajı göreceksiniz:

Argument list too long

Cobertura bir kabuk komut çalıştırmak çalışıyor:

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()); 
     } 
} 
0: Aslında
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); 
} 

, eklenti cobertura çalıştırmak için bir java sürecini yürütmek için çalışıyor

Öncelikle, cobertura DEBUG izlerini, çalıştırılan kabuk komutunu gösterecek şekilde etkinleştirin.

Sorunun, sürüm 2.5.1'de kullanılan sürüm 2.6'da kullanılan sınıf yolu olacağını düşünüyorum.

, ayıklama izlerini etkinleştirmek ve sonucu yayınlamak edin: alaka hatlarda

https://wiki.jenkins-ci.org/display/JENKINS/Logging

2

Bu sınırları fakat yardım sunabilir

Bu linux sınırlama nedeniyle oluşur sayede argümanlar can' Eğer okunan bir kez Jenkins içinde MAX_ARG_STRLEN https://github.com/torvalds/linux/blob/master/include/uapi/linux/binfmts.h

: t boyutunda Bkz Linux Kernel sabit 128KB aşan/Bu değerin aşıldığı bir değişkene, bu hatayı duyarsınız. Benim durumumda, Jenkins işini başlatan bir github webhook'um vardı ve bu sınıra göre bir string'e bir yük yükü parametresi ayarladım. Bu parametreyi okumaya çalışırken bu hatayı atardım.

soruna için, ben Sen ebeveyn işi bir başarısızlık atmak sağlayabilirsiniz ebeveyn

değeri okumak için bir dinlenme-api çağrısı kullanan bir çocuk işim var, ama çocuk işi izin her durumda başlatılabilir. Aşağıda Bilgiyi çekmek için kullanılan bir hafif rafine fonksiyonudur

def get_parameter_value_from_parent(): 
    host = 'https://[YOUR_COMPANY].ci.cloudbees.com' 
    this_build_url = os.environ.get('BUILD_URL') 
    request_auth = (JENKINS_USER, JENKINS_TOKEN) 

    url = '{0}/api/json'.format(this_build_url) 
    parameter_name = 'payload' 
    payload = '' 

    # 
    # Get the upstreamBuild number, and the upstreamUrl 
    # so we can put together a link to the upstream job 
    # 

    response = requests.get(url, auth=request_auth) 
    this_build = json.loads(response) 

    build_number = '' 
    short_url = '' 
    actions = this_build['actions'] 
    for action in actions: 
     if action.get('causes'): 
      for cause in action.get('causes'): 
       build_number = cause['upstreamBuild'] 
       short_url = cause['upstreamUrl'] 

    parent_url = '{host}/{short_url}{build}/api/json'.format(host=host, 
      short_url=short_url, build=build_number) 

    # 
    # Now get the payload from the parent job by making REST api call 
    # 

    response = requests.get(parent_url, auth=request_auth) 
    upstream_build = json.loads(response) 

    actions = upstream_build['actions'] 
    for action in actions: 
     if action.get('parameters'): 
      for parameter in action.get('parameters'): 
       if parameter['name'] == parameter_name: 
        value = parameter['value'] 
        payload = value 
        return payload 

    print 'Error: Unable to return payload from parent jenkins job: {0}'.format(parent_url) 
    sys.exit(1) 
İlgili konular