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

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

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • workflow-cps-plugin
    • None
    • Jenkins 2.170, workflow-cps-plugin 2.65

       

      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.

          [JENKINS-56916] Passing method invocation as another method input default value breaks the second method

          Grigor Lechev created issue -
          Grigor Lechev made changes -
          Description Original:  
          {code:java}
          String test() {
              println("test")
              return "12345"
          }def testtest(String b = test()) {
              println("testtest")
          }testtest()
          println ("END"){code}
           

          This script produces the following:

           

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

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

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

           
          {noformat}
          [Pipeline] Start of Pipeline (hide)
          [Pipeline] echo
          test
          [Pipeline] echo
          testtest
          [Pipeline] echo
          END
          [Pipeline] End of Pipeline
          Finished: SUCCESS
          {noformat}
          This doesn't look like a regression - it's reproduced in older versions as well.
          New:  
          {code:java}
          String test() {
              println("test")
              return "12345"
          }

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

          testtest()
          println ("END"){code}
           

          This script produces the following:

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

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

           
          {code:java}
          @NonCPS
          String test() {
              println("test")
              return "12345"
          }

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

          testtest()
          println ("END")
          {code}
           

          produces:

           
          {noformat}
          [Pipeline] Start of Pipeline (hide)
          [Pipeline] echo
          test
          [Pipeline] echo
          testtest
          [Pipeline] echo
          END
          [Pipeline] End of Pipeline
          Finished: SUCCESS
          {noformat}
          This doesn't look like a regression - it's reproduced in older versions as well.

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

              Created:
              Updated: