Details

    • Similar Issues:

      Description

      We are Working on a Scripted Pipeline managed with SCM.
      Currently we are calling Class-Methods from the Pipeline to keep the code clean and Object orientated.

      The Problem we encounter is that every Time we call the `sh` command the whole Body after that call will be skipped and the current state will return to the pipeline. This would be as follows:

      pipeline.groovy
      ...
      ums = new UmsHandler(this)
      ums.getSessionID()
      UmsHandler.groovy
      UmsHandler(steps) {
        this.steps = steps
      }
      
      @NonCPS
      String getSessionID() {
        def exitcode = steps.sh(script: "getSessionID", returnStatus: true)
        if (exitcode != 0) {
          foo
        }
      }
      

      every Time we execute the command (and it is executed we log that on the Machine) the code after that execution won't be executed. The Script will return to the pipeline and proceed there.

      I'm not sure if this is the correct way to execute a Command from a Class or even if this behavior is expected, but I would appropriate a Solution to this Problem.

        Attachments

          Activity

          Hide
          abayer Andrew Bayer added a comment -

          That's expected - steps called within a @NonCPS method do not have consistent behavior. So don't do that. =)

          Show
          abayer Andrew Bayer added a comment - That's expected - steps called within a @NonCPS method do not have consistent behavior. So don't do that. =)
          Hide
          dageissl Daniel Geißler added a comment -

          I've had a similar situation with a  @NonCPS annotated method in a groovy class. Even though the method did only some regex evaluation.

          I observed that when doing subsequent code updates, the executed code was frozen at an old level. After removing the annotation the updated implementation was kicking in and the method worked as expected (even though Matcher instances tend to be not serializeable).

          Is it possible, that @NonCPS annotated methods in classes are being cached by the CPS mechanism?

          Show
          dageissl Daniel Geißler added a comment - I've had a similar situation with a   @NonCPS  annotated method in a groovy class. Even though the method did only some regex evaluation. I observed that when doing subsequent code updates, the executed code was frozen at an old level. After removing the annotation the updated implementation was kicking in and the method worked as expected (even though Matcher instances tend to be not serializeable). Is it possible, that @NonCPS annotated methods in classes are being cached by the CPS mechanism?

            People

            • Assignee:
              Unassigned
              Reporter:
              biskit1943 Maximilian Konter
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: