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

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Blocker Blocker
    • email-ext-plugin
    • None
    • Jenkins 1.592 , Email-ext plugin - ver 2.39 , Java runtime version 1.7.0_25-b17

      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.

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

          Alex Earl added a comment -

          A and B are strings, yet you are checking them against true?

          Alex Earl added a comment - A and B are strings, yet you are checking them against true?

          Nirav Shah added a comment -

          I guess it got solved.

          I did two things :
          1. Restarted Jenkins.
          2. There was another script before which had some print command afte the line cancel=true and I read somewhere that cancel=true has to be the last line in the script. Well now this is a bug that cancel=true works only if it is the last line. Still I got it working for now that way.

          Nirav Shah added a comment - I guess it got solved. I did two things : 1. Restarted Jenkins. 2. There was another script before which had some print command afte the line cancel=true and I read somewhere that cancel=true has to be the last line in the script. Well now this is a bug that cancel=true works only if it is the last line. Still I got it working for now that way.

          Nirav Shah added a comment -

          A and B are boolean variables which are of string values true and false (as mentioned in the help function for boolean variables. Also I could see it print and not print depending on values of A and B so that is working.

          Nirav Shah added a comment - A and B are boolean variables which are of string values true and false (as mentioned in the help function for boolean variables. Also I could see it print and not print depending on values of A and B so that is working.

          Daniel Beck added a comment -

          Without looking at the sources, this looks a lot like the return value of the script is used rather than the value of the cancel variable?

          Daniel Beck added a comment - Without looking at the sources, this looks a lot like the return value of the script is used rather than the value of the cancel variable?

          Nirav Shah added a comment -

          Thanks for the prompt replies. I would say it is still a issue that it works only if cancel=true is the last line in the script. Assume everything else is working just fine.

          Nirav Shah added a comment - Thanks for the prompt replies. I would say it is still a issue that it works only if cancel=true is the last line in the script. Assume everything else is working just fine.

          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.

          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.

          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.

          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.

          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.

          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.

          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.

          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.

          Alex Earl added a comment -

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

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

            slide_o_mix Alex Earl
            nshah Nirav Shah
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: