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

Running asynchronous code inside a @NonCPS method should fail cleanly

    XMLWordPrintable

    Details

    • Similar Issues:
    • Released As:
      workflow-cps 2.71

      Description

      User-visible bit: throws an error

       

      Currently if you run a step with asynchronous execution (which is to say, almost all of them, since AbstractSynchronousNonBlockingStepExecution counts) inside a method marked @NonCPS, or otherwise not transformed (for example because of JENKINS-26481), you get bizarre results: the return value of the step becomes the return value of the method, regardless of what was supposed to happen in the rest of the method. This is because CpsCallableInvocation is thrown from DSL.invokeMethod and interrupts the method's execution.

      This is very confusing behavior. It would be better for CpsCallableInvocation.<init> to somehow detect that it is inside an untransformed method and throw a comprehensible error.

        Attachments

          Issue Links

            Activity

            Hide
            yngvark Yngvar Kristiansen added a comment -

            Any progress on this?

            Show
            yngvark Yngvar Kristiansen added a comment - Any progress on this?
            Hide
            jglick Jesse Glick added a comment -

            No, I had a prototype but stopped work on this.

            Show
            jglick Jesse Glick added a comment - No, I had a prototype but stopped work on this.
            Hide
            dnusbaum Devin Nusbaum added a comment -

            A fix for this issue was released in Pipeline: Groovy Plugin version 2.71.

            Show
            dnusbaum Devin Nusbaum added a comment - A fix for this issue was released in Pipeline: Groovy Plugin version 2.71.
            Hide
            fwilhe Florian Wilhelm added a comment -

            Hi Devin Nusbaum, I’m afraid this change broke our Jenkinsfile runner based testing because the warnings will be thrown as an exception there. Reproducer here https://github.com/fwilhe/repro-cps-issue

            I know we have to fix this in a proper way, but is there some way to turn it into warnings also on Jenkinsfile runner and not have it throw an exception?

            Show
            fwilhe Florian Wilhelm added a comment - Hi Devin Nusbaum , I’m afraid this change broke our Jenkinsfile runner based testing because the warnings will be thrown as an exception there. Reproducer here  https://github.com/fwilhe/repro-cps-issue I know we have to fix this in a proper way, but is there some way to turn it into warnings also on Jenkinsfile runner and not have it throw an exception?
            Hide
            jglick Jesse Glick added a comment -

            Florian Wilhelm JFR is being tracked in JENKINS-58407.

            Show
            jglick Jesse Glick added a comment - Florian Wilhelm JFR is being tracked in JENKINS-58407 .

              People

              • Assignee:
                jglick Jesse Glick
                Reporter:
                jglick Jesse Glick
              • Votes:
                16 Vote for this issue
                Watchers:
                26 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: