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

currentBuild.getBuildCauses(type) fails when type is a cause contributed by a plugin

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Labels:
      None
    • Environment:
      Jenkins ver. 2.138.3
      workflow support 2.22
      all latest plugin uploads as of issue creation
    • Similar Issues:
    • Released As:
      workflow-support 2.24

      Description

      currentBuild.getBuildCauses(type) was added in 2.22 which seems to work for Jenkins built-in causes but fails when trying to look-up causes contributed by plugins.

      Example - replay after building first time with failure to see echo'd output shown below:

      echo "${currentBuild.buildCauses}"
      currentBuild.getBuildCauses('org.jenkinsci.plugins.workflow.cps.replay.ReplayCause')
      

      Fails with: 

      [Pipeline] echo
      [[_class:hudson.model.Cause$UserIdCause, shortDescription:Started by user anonymous, userId:null, userName:anonymous], [_class:org.jenkinsci.plugins.workflow.cps.replay.ReplayCause, shortDescription:Replayed #9]]
      [Pipeline] End of Pipeline
      java.lang.ClassNotFoundException: org.jenkinsci.plugins.workflow.cps.replay.ReplayCause
      	at jenkins.util.AntClassLoader.findClassInComponents(AntClassLoader.java:1374)
      	at jenkins.util.AntClassLoader.findClass(AntClassLoader.java:1327)
      	at jenkins.util.AntClassLoader.loadClass(AntClassLoader.java:1080)
      	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      	at java.lang.Class.forName0(Native Method)
      	at java.lang.Class.forName(Class.java:264)
      	at org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper.getBuildCauses(RunWrapper.java:152)
              ...

       My presumption is that it is not using the correct classloader.

        Attachments

          Activity

          Hide
          dnusbaum Devin Nusbaum added a comment -

          This was fixed in workflow-support 2.24 by PR 85.

          Show
          dnusbaum Devin Nusbaum added a comment - This was fixed in workflow-support 2.24 by PR 85 .

            People

            • Assignee:
              Unassigned
              Reporter:
              mkobit Mike Kobit
            • Votes:
              3 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: