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

noncps function is silently aborted

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      The function annotated with @NonCPS in the attached Jenkinsfile is not executed completely. There is no report about that. If it is not allowed to call e.g. 'sh' in a NonCPS context than i would at least expect to get an Exception. But silently not executing parts of the test-code is really bad.

      If the pipeline will be extended, that it returns some Integer value, the return value is null in the caller.

      This is a snippet from the attached pipeline

      steps
      {
       println('call cps')
       cps() println('call non-cps')
       non_cps()
       println('exit pipeline') 
      }
      

       

      The cps and non_cps functions are the same, but with different println and the non_cps is annoted with @NonCPS:

      *cps()
      {
         println("enter cps")
         sh "ls"
         println("exit cps") 
      }
      

      And this is the relevant part of the build log

      00:00:05.956 call cps[Pipeline] echo

      00:00:06.621 cps - enter[Pipeline] sh

      00:00:07.032 [workspace@2] Running shell script*

      00:00:07.288* + ls[Pipeline] echo

      00:00:07.730 cps - exit[Pipeline] echo

      00:00:08.052 call non-cps[Pipeline] echo

      00:00:08.640 non_cps - enter[Pipeline] sh

      00:00:09.007 [workspace@2] Running shell script*

      00:00:09.263* + ls[Pipeline] echo


      the non_cpx exit print is missing here!

       

      00:00:09.782 exit pipeline

        Attachments

          Activity

          Hide
          abayer Andrew Bayer added a comment -

          You're trying to execute sh inside a @NonCPS-annotated method - that won't work. So yeah, it aborting is expected, but it should be giving you some feedback.

          Show
          abayer Andrew Bayer added a comment - You're trying to execute sh inside a @NonCPS -annotated method - that won't work. So yeah, it aborting is expected, but it should be giving you some feedback.
          Hide
          hughsaunders Hugh Saunders added a comment -

          It is in the docs that you can't call a CPS function from a NonCPS function, but its really hard to debug, as the pipeline just halts, and the result is success! Theres nothing in the build log, or the system log to indicate what the problem might be.

           

          It would be really useful to throw an exception or log something to inform the user that calling a CPS function from a non CPS function is not supported. 

          Show
          hughsaunders Hugh Saunders added a comment - It is in the docs that you can't call a CPS function from a NonCPS function, but its really hard to debug, as the pipeline just halts, and the result is success! Theres nothing in the build log, or the system log to indicate what the problem might be.   It would be really useful to throw an exception or log something to inform the user that calling a CPS function from a non CPS function is not supported. 

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            manut Manuel Traut
            Votes:
            4 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated: