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

GET /job/:job-name/:run-id/wfapi/describe,somtimes return 500 error

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • None
    • Jenkins Version: 2.302
      pipeline-stage-view-plugin Version: 2.19

      attachment image is exception stack.

      When the FlowExecution 'isComplete' return true,get the 'Result' from WorkflowRun's function 'getResult',but maybe this moment result is null

      original code is :

      private void initStatus(WorkflowRun run) {
          FlowExecution execution = run.getExecution();
      
          if (execution == null) {
              setStatus(StatusExt.NOT_EXECUTED);
          } else if (execution.getCauseOfFailure() != null) {
              setStatus(StatusExt.valueOf(execution.getCauseOfFailure()));
          } else if (execution.isComplete()) {
              Result r = run.getResult();
              setStatus(StatusExt.valueOf(r));
          } else if (isPendingInput(run)) {
              setStatus(StatusExt.PAUSED_PENDING_INPUT);
          } else {
              setStatus(StatusExt.IN_PROGRESS);
          }
      }

      Maybe the correct code to get 'Result' is :

      private void initStatus(WorkflowRun run) {
          FlowExecution execution = run.getExecution();
      
          if (execution == null) {
              setStatus(StatusExt.NOT_EXECUTED);
          } else if (execution.getCauseOfFailure() != null) {
              setStatus(StatusExt.valueOf(execution.getCauseOfFailure()));
          } else if (execution.isComplete()) {
              Result r = run.getResult();
             // ensure Result is not null
             if(null == r) {
               r =((FlowEndNode)execution.getCurrentHeads().get(0)).getResult();
             }
             setStatus(StatusExt.valueOf(r));
          } else if (isPendingInput(run)) {
              setStatus(StatusExt.PAUSED_PENDING_INPUT);
          } else {
              setStatus(StatusExt.IN_PROGRESS);
          }
      }
      

            mierihazai kun
            mierihazai kun
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: