[ 
https://jira.codehaus.org/browse/CONTINUUM-1965?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=363275#comment-363275
 ] 

Brent N Atkinson commented on CONTINUUM-1965:
---------------------------------------------

I took a look at the history and it appears that multiple issues are in play.

1.) {{DefaultShellCommandHelper}}, which is responsible for executing the 
actual command line and gathering output, did not properly close the writer it 
used to capture build output. When exceptions were thrown during shell 
execution, the file contents are not written to the filesystem.

{code:java|title=DefaultShellCommandHelper#executeShellCommand}
        Writer writer = new FileWriter( output );

        StreamConsumer consumer = new WriterStreamConsumer( writer );

        int exitCode = CommandLineUtils.executeCommandLine( cl, consumer, 
consumer );  // Exception thrown!!!

        writer.flush();

        writer.close();  // Never called, so the file system is never updated 
and the contents are lost
{code}

2.) {{ExecuteBuilderContinuumAction#execute}}, which delegates to 
{{DefaultShellCommandHelper}} to run the actual shell commands, handled 
exceptions differently than command failure or success.

{code:java|title=ExecuteBuilderContinuumAction#execute}
...
        try
        {
            notifier.runningGoals( project, buildDefinition, buildResult );

            File buildOutputFile = configurationService.getBuildOutputFile( 
buildResult.getId(), project.getId() );

            ContinuumBuildExecutionResult result = buildExecutor.build( 
project, buildDefinition, buildOutputFile );  // Exception thrown!!!

            buildResult.setState( result.getExitCode() == 0 ? 
ContinuumProjectState.OK : ContinuumProjectState.FAILED );

            buildResult.setExitCode( result.getExitCode() );
        }
        catch ( Throwable e )
        {
            getLogger().error( "Error running buildResult", e );

            buildResult.setState( ContinuumProjectState.ERROR );  // Result is 
set to error, not failed or ok

            buildResult.setError( ContinuumUtils.throwableToString( e ) ); // 
Error message is the stack trace from the throwable
        }
...
{code}

When the cancel exception is thrown, the build result is set by the exception 
handler to ERROR and the message is the stack trace. This is consistent with 
the observed behavior, if this message is displayed rather than the build 
output (which is unavailable since it is never written).

3.) It turns out that if the build output file existed, both the result (ERROR) 
and the actual output would be available for display. However, due to 1.) the 
file contents are always going to be missing. This may have lead to the 
behavior given in {{buildResult.jsp}}:

{code:html|title=buildResult.jsp}
        <ww:if test="buildResult.state == 4">
          <!-- If the build result is ERROR, just show the message (the stack 
trace) -->
          <h4><ww:text name="buildResult.buildError"/></h4>
          <div style="width:100%; height:500px; overflow:auto; border-style: 
solid; border-width: 1px">
            <pre><ww:property value="buildResult.error"/></pre>
          </div>
        </ww:if>
        <ww:else>
          <!-- otherwise, show a 'No Output' message or the file contents 
(which never exist) -->
          <h4><ww:text name="buildResult.buildOutput"/></h4>
          <p>
            <ww:if test="buildOutput == ''">
                <ww:text name="buildResult.noOutput"/>
            </ww:if>
            <ww:else>
              <ww:url id="buildOutputTextUrl" action="buildOutputText">
                <ww:param name="projectId" value="projectId"/>
                <ww:param name="buildId" value="buildId"/>
              </ww:url>
              <ww:a href="%{buildOutputTextUrl}"><ww:text 
name="buildResult.buildOutput.text"/></ww:a>
              <div style="width:100%; height:500px; overflow:auto; 
border-style: solid; border-width: 1px">
                <pre><ww:property value="buildOutput"/></pre>
              </div>
            </ww:else>
          </p>
        </ww:else>
{code}

As the comments highlight above, the observed behavior is fully visible: when 
the result is caused by an exception show the stack trace and nothing else. 

By fixing the file handling (addressed in 1.5) and changing the conditionals to 
always show information if it is available (both error and build output), the 
diagnostic information should be greatly improved for these cases.

> Can't view build log is build is cancel because of timeout
> ----------------------------------------------------------
>
>                 Key: CONTINUUM-1965
>                 URL: https://jira.codehaus.org/browse/CONTINUUM-1965
>             Project: Continuum
>          Issue Type: Bug
>    Affects Versions: 1.2.1
>         Environment: Ubuntu8.04/tomcat6
>            Reporter: Luc Willems
>            Assignee: Wendy Smoak
>         Attachments: 
> build-result-screen-showing-build-error-rather-than-output.jpg
>
>
> I have some site-deploy build targets that for some unkown reason take a long 
> time (> 1 hr)
> mij default build timeout is set to 1 hr
> when the build is cancel because of time out i see this error :
> org.apache.maven.continuum.execution.ContinuumBuildCancelledException: The 
> build was cancelled
>         at 
> org.apache.maven.continuum.execution.AbstractBuildExecutor.executeShellCommand(AbstractBuildExecutor.java:289)
>         at 
> org.apache.maven.continuum.execution.maven.m2.MavenTwoBuildExecutor.build(MavenTwoBuildExecutor.java:178)
>         at 
> org.apache.maven.continuum.core.action.ExecuteBuilderContinuumAction.execute(ExecuteBuilderContinuumAction.java:124)
>         at 
> org.apache.maven.continuum.buildcontroller.DefaultBuildController.performAction(DefaultBuildController.java:431)
>         at 
> org.apache.maven.continuum.buildcontroller.DefaultBuildController.build(DefaultBuildController.java:167)
>         at 
> org.apache.maven.continuum.buildcontroller.BuildProjectTaskExecutor.executeTask(BuildProjectTaskExecutor.java:50)
>         at 
> org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor$ExecutorRunnable$1.run(ThreadedTaskQueueExecutor.java:116)
>         at 
> edu.emory.mathcs.backport.java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
>         at 
> edu.emory.mathcs.backport.java.util.concurrent.FutureTask.run(FutureTask.java:178)
>         at 
> edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
>         at 
> edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
>         at java.lang.Thread.run(Thread.java:595)
> Caused by: org.codehaus.plexus.util.cli.CommandLineException: Error while 
> executing external command, process killed.
>         at 
> org.codehaus.plexus.util.cli.CommandLineUtils.executeCommandLine(CommandLineUtils.java:199)
>         at 
> org.codehaus.plexus.util.cli.CommandLineUtils.executeCommandLine(CommandLineUtils.java:93)
>         at 
> org.apache.maven.continuum.utils.shell.DefaultShellCommandHelper.executeShellCommand(DefaultShellCommandHelper.java:131)
>         at 
> org.apache.maven.continuum.utils.shell.DefaultShellCommandHelper.executeShellCommand(DefaultShellCommandHelper.java:59)
>         at 
> org.apache.maven.continuum.execution.AbstractBuildExecutor.executeShellCommand(AbstractBuildExecutor.java:277)
>         ... 11 more
> Caused by: java.lang.InterruptedException
> This is normal but i would also like to see the build log to verify why it 
> was taken so long.
>  note : this is a multi module build (flex/java) with about 20 modules.



--
This message was sent by Atlassian JIRA
(v6.1.6#6162)

Reply via email to