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

Create a nonCPS() wrapper to simplify nonCPS invocations

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Minor Minor
    • workflow-cps-plugin
    • None

      Currently any Pipeline developer needs to create a new method and to mark it as NonCPS in order to define a NonCPS code. It would be great to create a new NonCPS wrapper method, which allows writing code just within closure.

      Example:

      nonCPS.exec() {
          Object fooBar = // non serializable object
          fooBar.doSomething()
      }
      

          [JENKINS-50666] Create a nonCPS() wrapper to simplify nonCPS invocations

          Jesse Glick added a comment -

          As noted in PR review, this is impossible as described. It would be possible in principle to introduce a new mechanism for delineating a lexical block within a method which is not CPS-transformed, though I do not know offhand what Groovy syntax would be suitable for this purpose, and it would certainly require nontrivial changes to CpsTransformer.

          Jesse Glick added a comment - As noted in PR review, this is impossible as described. It would be possible in principle to introduce a new mechanism for delineating a lexical block within a method which is not CPS-transformed, though I do not know offhand what Groovy syntax would be suitable for this purpose, and it would certainly require nontrivial changes to CpsTransformer .

            oleg_nenashev Oleg Nenashev
            oleg_nenashev Oleg Nenashev
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: