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

Passing method invocation as another method input default value breaks the second method

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Critical
    • Resolution: Unresolved
    • Component/s: workflow-cps-plugin
    • Labels:
      None
    • Environment:
      Jenkins 2.170, workflow-cps-plugin 2.65
    • Similar Issues:

      Description

       

      String test() {
          println("test")
          return "12345"
      }
      
      def testtest(String b = test()) {
          println("testtest")
      }
      
      testtest()
      println ("END")

       

      This script produces the following:

       

      [Pipeline] Start of Pipeline
      [Pipeline] echo
      test
      [Pipeline] echo
      END
      [Pipeline] End of Pipeline
      Finished: SUCCESS
      

       

      the  ' println("testtest")' is not invoked. Adding @NonCPS annotation is the available workaround:

       

      @NonCPS
      String test() {
          println("test")
          return "12345"
      }
      
      def testtest(String b = test()) {
          println("testtest")
      }
      
      testtest()
      println ("END")
      

       

      produces:

       

      [Pipeline] Start of Pipeline (hide)
      [Pipeline] echo
      test
      [Pipeline] echo
      testtest
      [Pipeline] echo
      END
      [Pipeline] End of Pipeline
      Finished: SUCCESS
      

      This doesn't look like a regression - it's reproduced in older versions as well.

        Attachments

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              Unassigned
              Reporter:
              mooncrosser Grigor Lechev
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: