Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-2786

ClassCastException when posting external job results

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • build-publisher-plugin
    • None
    • Platform: All, OS: All

      Found in version 1.268

      I am trying to publish results of an external job to my Hudson instance, per the
      instructions here:
      http://hudson.gotdns.com/wiki/display/JENKINS/Monitoring+external+jobs

      The job succeeds (I have tried it with "echo hello", "/bin/true", various
      trivial things) and publishes the XML to the Hudson server. But the server
      reports it as a failure always with no outputs.

      I verified that the XML being submitted over http is correct and indicates success.

      I remote debugged the server, and tracked the issue to a ClassCastException
      being thrown here:

      return (Executor)Thread.currentThread();

      Executor.currentExecutor() line: 294
      Computer.currentComputer() line: 524
      ExternalRun(Run<JobT,RunT>).run(Run$Runner) line: 815
      ExternalRun.acceptRemoteSubmission(Reader) line: 71
      ExternalJob.doPostBuildResult(StaplerRequest, StaplerResponse) line: 63

      The problem seems to be that the remote job submission is not executing in an
      Executor thread - it's executing in a server thread (RequestHandlerThread for
      the Winstone container) - so the cast to Executor is failing.

          [JENKINS-2786] ClassCastException when posting external job results

          Alan Harder added a comment -

          oops, dvrzalik... I started working on this before I saw that a bug is filed and
          is already assigned.. sorry! Committing my fix now.. feel free to rework
          anything if needed.

          vessva, thanks for the detailed debugging!

          Alan Harder added a comment - oops, dvrzalik... I started working on this before I saw that a bug is filed and is already assigned.. sorry! Committing my fix now.. feel free to rework anything if needed. vessva, thanks for the detailed debugging!

          Code changed in hudson
          User: : mindless
          Path:
          trunk/hudson/main/core/src/main/java/hudson/model/Computer.java
          trunk/hudson/main/core/src/main/java/hudson/model/Executor.java
          http://fisheye4.cenqua.com/changelog/hudson/?cs=14176
          Log:
          [FIXED JENKINS-2786] Fix posting external job results.
          Made Executor.currentExecutor() return null if current thread is not an executor,
          and Computer.currentComputer() return Hudson.getInstance().toComputer() if
          currentExecutor returns null (must be on master if not in an executor).
          This avoids exception causing posting of external job results to fail.

          SCM/JIRA link daemon added a comment - Code changed in hudson User: : mindless Path: trunk/hudson/main/core/src/main/java/hudson/model/Computer.java trunk/hudson/main/core/src/main/java/hudson/model/Executor.java http://fisheye4.cenqua.com/changelog/hudson/?cs=14176 Log: [FIXED JENKINS-2786] Fix posting external job results. Made Executor.currentExecutor() return null if current thread is not an executor, and Computer.currentComputer() return Hudson.getInstance().toComputer() if currentExecutor returns null (must be on master if not in an executor). This avoids exception causing posting of external job results to fail.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          core/src/main/java/hudson/model/Computer.java
          http://jenkins-ci.org/commit/jenkins/0b0b868805e43d5b7bcafbdf22a59960a3baeeb0
          Log:
          JENKINS-2786 Makes no sense for Computer.currentComputer to return MasterComputer when not on an executor thread.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: core/src/main/java/hudson/model/Computer.java http://jenkins-ci.org/commit/jenkins/0b0b868805e43d5b7bcafbdf22a59960a3baeeb0 Log: JENKINS-2786 Makes no sense for Computer.currentComputer to return MasterComputer when not on an executor thread.

          dogfood added a comment -

          Integrated in jenkins_main_trunk #3811
          JENKINS-2786 Makes no sense for Computer.currentComputer to return MasterComputer when not on an executor thread. (Revision 0b0b868805e43d5b7bcafbdf22a59960a3baeeb0)

          Result = SUCCESS
          jesse glick : 0b0b868805e43d5b7bcafbdf22a59960a3baeeb0
          Files :

          • core/src/main/java/hudson/model/Computer.java

          dogfood added a comment - Integrated in jenkins_main_trunk #3811 JENKINS-2786 Makes no sense for Computer.currentComputer to return MasterComputer when not on an executor thread. (Revision 0b0b868805e43d5b7bcafbdf22a59960a3baeeb0) Result = SUCCESS jesse glick : 0b0b868805e43d5b7bcafbdf22a59960a3baeeb0 Files : core/src/main/java/hudson/model/Computer.java

          Code changed in jenkins
          User: Jesse Glick
          Path:
          cps/src/main/java/org/jenkinsci/plugins/workflow/cps/EnvActionImpl.java
          support/src/main/java/org/jenkinsci/plugins/workflow/support/DefaultStepContext.java
          http://jenkins-ci.org/commit/workflow-plugin/4d67cbd404488e810db2c3a5b05ed8fa8f9c692d
          Log:
          Can revert to the standard Run.getEnvironment(TaskListener) now that Computer.currentComputer is saner (cf. JENKINS-2786).

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: cps/src/main/java/org/jenkinsci/plugins/workflow/cps/EnvActionImpl.java support/src/main/java/org/jenkinsci/plugins/workflow/support/DefaultStepContext.java http://jenkins-ci.org/commit/workflow-plugin/4d67cbd404488e810db2c3a5b05ed8fa8f9c692d Log: Can revert to the standard Run.getEnvironment(TaskListener) now that Computer.currentComputer is saner (cf. JENKINS-2786 ).

          Code changed in jenkins
          User: Jesse Glick
          Path:
          support/src/main/java/org/jenkinsci/plugins/workflow/support/DefaultStepContext.java
          http://jenkins-ci.org/commit/workflow-support-plugin/b0afca7ffe655cc96889dca226921d12587525d3
          Log:
          Can revert to the standard Run.getEnvironment(TaskListener) now that Computer.currentComputer is saner (cf. JENKINS-2786).
          Originally-Committed-As: 4d67cbd404488e810db2c3a5b05ed8fa8f9c692d

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: support/src/main/java/org/jenkinsci/plugins/workflow/support/DefaultStepContext.java http://jenkins-ci.org/commit/workflow-support-plugin/b0afca7ffe655cc96889dca226921d12587525d3 Log: Can revert to the standard Run.getEnvironment(TaskListener) now that Computer.currentComputer is saner (cf. JENKINS-2786 ). Originally-Committed-As: 4d67cbd404488e810db2c3a5b05ed8fa8f9c692d

          Code changed in jenkins
          User: Jesse Glick
          Path:
          cps/src/main/java/org/jenkinsci/plugins/workflow/cps/EnvActionImpl.java
          http://jenkins-ci.org/commit/workflow-cps-plugin/1fca0aebc2b9ba5593af550d85e2b7a70f2824ef
          Log:
          Can revert to the standard Run.getEnvironment(TaskListener) now that Computer.currentComputer is saner (cf. JENKINS-2786).
          Originally-Committed-As: 4d67cbd404488e810db2c3a5b05ed8fa8f9c692d

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: cps/src/main/java/org/jenkinsci/plugins/workflow/cps/EnvActionImpl.java http://jenkins-ci.org/commit/workflow-cps-plugin/1fca0aebc2b9ba5593af550d85e2b7a70f2824ef Log: Can revert to the standard Run.getEnvironment(TaskListener) now that Computer.currentComputer is saner (cf. JENKINS-2786 ). Originally-Committed-As: 4d67cbd404488e810db2c3a5b05ed8fa8f9c692d

            mindless Alan Harder
            vessva vessva
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: