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

Success and failure trigger work even after setting the cancel variable to true in the pre-send script

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Blocker
    • Resolution: Fixed
    • Component/s: email-ext-plugin
    • Labels:
      None
    • Environment:
      Jenkins 1.592 , Email-ext plugin - ver 2.39 , Java runtime version 1.7.0_25-b17
    • Similar Issues:

      Description

      If I set the cancel variable to true , there should be no email sent but still email is triggered and sent for success and failure triggers.

        Attachments

          Activity

          Hide
          nshah Nirav Shah added a comment -

          I am not using any return variable from the script. I just wanted email sending to be cancelled when I set cancel to be true. However, seeing this kind of behaviour it does indicate that the email sending does not solely depend on cancel variable for plugin Or it get over ridden by something fishy in during compilation.

          Show
          nshah Nirav Shah added a comment - I am not using any return variable from the script. I just wanted email sending to be cancelled when I set cancel to be true. However, seeing this kind of behaviour it does indicate that the email sending does not solely depend on cancel variable for plugin Or it get over ridden by something fishy in during compilation.
          Hide
          slide_o_mix Alex Earl added a comment -

          This is how the plugin gets the value of "cancel"

          Object output = shell.evaluate(script);
          if (output != null) {
              pw.println("Result: " + output);
              cancel = ((Boolean) shell.getVariable("cancel"));
              debug(context.getListener().getLogger(), "Pre-send script set cancel to %b", cancel);
          }
          

          The unit tests show that setting cancel to true work, so something else is possibly interfering.

          Show
          slide_o_mix Alex Earl added a comment - This is how the plugin gets the value of "cancel" Object output = shell.evaluate(script); if (output != null ) { pw.println( "Result: " + output); cancel = (( Boolean ) shell.getVariable( "cancel" )); debug(context.getListener().getLogger(), "Pre-send script set cancel to %b" , cancel); } The unit tests show that setting cancel to true work, so something else is possibly interfering.
          Hide
          slide_o_mix Alex Earl added a comment -

          The issue is actually in the code I pasted before. If the last line doesn't evaluate to some value, the output variable will be set to null and the value of cancel will never be updated. This will be fixed in the next version.

          Show
          slide_o_mix Alex Earl added a comment - The issue is actually in the code I pasted before. If the last line doesn't evaluate to some value, the output variable will be set to null and the value of cancel will never be updated. This will be fixed in the next version.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Alex Earl
          Path:
          src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java
          src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherTest.java
          http://jenkins-ci.org/commit/email-ext-plugin/27fbded960faec271591a284709dad6dde3af4c0
          Log:
          Fix JENKINS-27448

          Remove check for output != null.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Alex Earl Path: src/main/java/hudson/plugins/emailext/ExtendedEmailPublisher.java src/test/java/hudson/plugins/emailext/ExtendedEmailPublisherTest.java http://jenkins-ci.org/commit/email-ext-plugin/27fbded960faec271591a284709dad6dde3af4c0 Log: Fix JENKINS-27448 Remove check for output != null.
          Hide
          slide_o_mix Alex Earl added a comment -

          Removed check for null that caused the cancel value to not be updated.

          Show
          slide_o_mix Alex Earl added a comment - Removed check for null that caused the cancel value to not be updated.

            People

            • Assignee:
              slide_o_mix Alex Earl
              Reporter:
              nshah Nirav Shah
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: