2015-04-08 8 views
7

मैं कोबर्टूरा प्लगइन का उपयोग कर कोड कवरेज रिपोर्ट जेनरेट करने की कोशिश कर रहा हूं।कोबर्टुरा तर्क सूची बहुत लंबे समय तक देता है

मैं अपने 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> 

जब मैं इस लक्ष्य को यू -B स्वच्छ का उपयोग कर अपने प्रोजेक्ट का निर्माण Cobertura स्थापित: Cobertura, मैं अपने जेनकींस पर नीचे त्रुटि मिलती है सीआई

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 

निर्माण मेरी खिड़कियां मशीन पर सफल है, लेकिन जेनकींस पर विफल रहता है। जब मैं कोबर्टूरा संस्करण को 2.5.1 तक डाउनग्रेड करता हूं तो यह त्रुटि दूर हो जाती है लेकिन मुझे कुछ पार्स अपवाद मिलते हैं क्योंकि 2.5.1 के लिए कोबर्टुरा के पार्सर जावा सिंटैक्स के साथ अद्यतित नहीं है।

किसी की मदद कर सकते हैं मुझे 2.6.0 संस्करणों के लिए इस काम की हो और Cobertura

+0

कृपया संलग्न सेटिंग्स के साथ एक स्क्रीनशॉट (त्रुटि जाँच और संक्षिप्तता के लिए टिप्पणियों बाहर Stripped)? – stanjer

+0

आपको किन सेटिंग्स की आवश्यकता है। मैंने सवालों में कोबर्टूरा प्लगइन सेटिंग्स चिपका दी है। स्थानीय (विंडोज़ मशीन) में उन सेटिंग्स के साथ यह cover.xml फ़ाइल उत्पन्न करता है लेकिन जेनकींस में यह – user2973475

+0

विफल रहता है, कृपया मेरा जवाब पढ़ें और हमें डीबग निशान दें ताकि मैं आपकी मदद कर सकूं – jfcorugedo

उत्तर

1

सभी खोल के लिए उच्च आदेश पंक्ति लंबाई के लिए एक सीमा है। UNIX/Linux/BSD सिस्टम की एक सीमा है कि कमांड लाइन तर्क और पर्यावरण चर के लिए कितने बाइट्स का उपयोग किया जा सकता है।

जब आप एक नई प्रक्रिया शुरू करने या एक कमांड इन सीमाओं को लागू किए जाते हैं टाइप करें और के रूप में स्क्रीन पर इस प्रकार आप एक त्रुटि संदेश देखेंगे:

Argument list too long

Cobertura एक शेल कमांड निष्पादित करने के लिए कोशिश कर रहा है:

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:
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); 
} 

वास्तव में, प्लगइन Cobertura चलाने के लिए एक जावा प्रक्रिया निष्पादित करने के लिए कोशिश कर रहा है

तो सबसे पहले, शेल कमांड निष्पादित करने के लिए कोबर्टुरा डेब्यूग निशान सक्षम करें।

मुझे लगता है कि समस्या वर्जन 2.6 में संस्करण 2.6.1 में उपयोग किए जाने वाले क्लासपाथ होगी।

कृपया, डिबग निशान को सक्षम और परिणाम पोस्ट:

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

2

प्रासंगिकता की तर्ज पर यह सीमाओं लेकिन सहायता प्रदान कर सकता है

यह एक linux सीमा के कारण होता है जिससे तर्क कर सकते हैं ' जेनकींस के भीतर MAX_ARG_STRLEN https://github.com/torvalds/linux/blob/master/include/uapi/linux/binfmts.h

आप से एक बार पढ़ें: टी देखें लिनक्स कर्नेल लगातार आकार में 128kb से अधिक/एक वेरिएबल जहां यह मान पार हो गया है, आप इस त्रुटि को दबाएंगे। मेरे मामले में, मेरे पास एक जिथब वेबहूक था जिसने जेनकींस जॉब लॉन्च किया और कुछ सीमाओं के लिए एक पेलोड पैरामीटर सेट किया> इस सीमा से। इस पैरामीटर को पढ़ने का प्रयास करने से यह त्रुटि फेंक जाएगी।

आदेश समस्या को हल करने के लिए, मैं एक आराम-api कॉल का उपयोग करता है माता पिता

से मूल्य को पढ़ने के लिए आप माता-पिता काम एक विफलता फेंक दे सकते हैं एक बच्चे को नौकरी है, लेकिन करने के लिए बच्चे को काम की अनुमति देते हैं सभी मामलों में लॉन्च किया जाना चाहिए। नीचे एक थोड़ा परिष्कृत समारोह मैं जानकारी खींचने के लिए प्रयोग किया जाता है

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) 
संबंधित मुद्दे