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

Nothing is executed after emailextrecipients() when called in method with NonCPS annotation

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • email-ext-plugin
    • None
    • Jenkins 2.89.2, email-ext-plugin 2.61

      With a method calling emailextrecipients() annotated by NonCPS, nothing is executed after that emailextrecipients() call. Example pipeline script and its output below:

      node("master") {
        mail()
      }
      
      @NonCPS
      void mail() {
        def to = emailextrecipients([[$class: 'RequesterRecipientProvider']])
        echo "Recipients: ${to}"
      
        if (to != null && !to.isEmpty()) {
          emailext to: to,
            replyTo: "\$DEFAULT_REPLYTO",
            subject: "\$DEFAULT_SUBJECT",
            body: "\$DEFAULT_CONTENT"
        }
      }
      [Pipeline] node
      Running on Jenkins in /var/lib/jenkins/jobs/Test-Workflow/workspace
      [Pipeline] {
      [Pipeline] emailextrecipients
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      Finished: SUCCESS
      

      Without NonCPS the output is:

      [Pipeline] node
      Running on Jenkins in /var/lib/jenkins/jobs/Test-Workflow/workspace
      [Pipeline] {
      [Pipeline] emailextrecipients
      [Pipeline] echo
      Recipients: atikhonova@parallels.com
      [Pipeline] emailext
      Sending email to: atikhonova@parallels.com
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      Finished: SUCCESS

            davidvanlaatum David van Laatum
            atikhono Anna Tikhonova
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: