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

AbstractBuildExecution#reportError should work will any kind of Build Step

      AbstractBuildExecution#reportError should work will any kind of Build Step.

      Right now, reportError supposes that all the build steps are Publishers, but according with the code it should work with any kind of BuildStep.

              private void reportError(BuildStep bs, Throwable e, BuildListener listener, boolean phase) {
                  final String publisher = ((Publisher) bs).getDescriptor().getDisplayName();
      
                  if (e instanceof AbortException) {
                      LOGGER.log(Level.FINE, "{0} : {1} failed", new Object[] {AbstractBuild.this, publisher});
                      listener.error("Publisher '" + publisher + "' failed: ");
                      listener.error(e.getMessage());
                  } else {
                      String msg = "Publisher '" + publisher + "' aborted due to exception: ";
                      e.printStackTrace(listener.error(msg));
                      LOGGER.log(WARNING, msg, e);
                  }
      
                  if (phase) {
                      setResult(Result.FAILURE);
                  }
              }
      

          [JENKINS-30730] AbstractBuildExecution#reportError should work will any kind of Build Step

          Félix Belzunce Arcos created issue -
          Félix Belzunce Arcos made changes -
          Description Original: AbstractBuildExecution#reportError should work will any kind of Build Step.

          Right now, reportError suppose that all the build steps are Publishers, but according with the code it should work with any kind of BuildStep.


          {code:java}
                  private void reportError(BuildStep bs, Throwable e, BuildListener listener, boolean phase) {
                      final String publisher = ((Publisher) bs).getDescriptor().getDisplayName();

                      if (e instanceof AbortException) {
                          LOGGER.log(Level.FINE, "{0} : {1} failed", new Object[] {AbstractBuild.this, publisher});
                          listener.error("Publisher '" + publisher + "' failed: ");
                          listener.error(e.getMessage());
                      } else {
                          String msg = "Publisher '" + publisher + "' aborted due to exception: ";
                          e.printStackTrace(listener.error(msg));
                          LOGGER.log(WARNING, msg, e);
                      }

                      if (phase) {
                          setResult(Result.FAILURE);
                      }
                  }
          {code}
           
          New: AbstractBuildExecution#reportError should work will any kind of Build Step.

          Right now, reportError supposes that all the build steps are Publishers, but according with the code it should work with any kind of BuildStep.


          {code:java}
                  private void reportError(BuildStep bs, Throwable e, BuildListener listener, boolean phase) {
                      final String publisher = ((Publisher) bs).getDescriptor().getDisplayName();

                      if (e instanceof AbortException) {
                          LOGGER.log(Level.FINE, "{0} : {1} failed", new Object[] {AbstractBuild.this, publisher});
                          listener.error("Publisher '" + publisher + "' failed: ");
                          listener.error(e.getMessage());
                      } else {
                          String msg = "Publisher '" + publisher + "' aborted due to exception: ";
                          e.printStackTrace(listener.error(msg));
                          LOGGER.log(WARNING, msg, e);
                      }

                      if (phase) {
                          setResult(Result.FAILURE);
                      }
                  }
          {code}
           
          Félix Belzunce Arcos made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Jesse Glick made changes -
          Jesse Glick made changes -
          Remote Link New: This issue links to "PR 1851 (Web Link)" [ 13175 ]
          Jesse Glick made changes -
          Link New: This issue is blocking JENKINS-26964 [ JENKINS-26964 ]

          Jesse Glick added a comment -

          This seems to be a regression in the LTS, preventing proper error diagnosis (even AbortException for user mistakes—not necessarily just plugin bugs), so I am proposing it for backport.

          Jesse Glick added a comment - This seems to be a regression in the LTS, preventing proper error diagnosis (even AbortException for user mistakes—not necessarily just plugin bugs), so I am proposing it for backport.
          Jesse Glick made changes -
          Labels New: diagnostics lts-candidate regression
          Priority Original: Minor [ 4 ] New: Major [ 3 ]

          Code changed in jenkins
          User: Oleg Nenashev
          Path:
          core/src/main/java/hudson/model/AbstractBuild.java
          test/src/test/java/hudson/model/AbstractBuildTest2.java
          http://jenkins-ci.org/commit/jenkins/725b6afeac4ac5b8821c095f3b093cd0daa3a526
          Log:
          [FIXED JENKINS-30730] Prevent ClassCastException in Abstractbuild::reportError() if the build step is not Publisher.

          This pull request integrates https://github.com/jenkinsci/jenkins/pulls/1851, which is a reworked version of https://github.com/jenkinsci/jenkins/pull/1846 from @fbelzunc (no original codelines left)

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oleg Nenashev Path: core/src/main/java/hudson/model/AbstractBuild.java test/src/test/java/hudson/model/AbstractBuildTest2.java http://jenkins-ci.org/commit/jenkins/725b6afeac4ac5b8821c095f3b093cd0daa3a526 Log: [FIXED JENKINS-30730] Prevent ClassCastException in Abstractbuild::reportError() if the build step is not Publisher. This pull request integrates https://github.com/jenkinsci/jenkins/pulls/1851 , which is a reworked version of https://github.com/jenkinsci/jenkins/pull/1846 from @fbelzunc (no original codelines left)

            fbelzunc Félix Belzunce Arcos
            fbelzunc Félix Belzunce Arcos
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: