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

Free style projects/jobs not sending email notification if removed the slave with post build action groovy script enabled

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Blocker Blocker
    • core
    • None
    • Jenkins 2.62
      Groovy 1.29
      Groovy Post build 2.3.1
      Docker plugin 0.16.2


      Hi All,

      I have my jenkins server set up such that we are deploying our jobs inside spawned docker containers. I have templates( for each docker image) created for each of the Docker Cloud instance inside my " http://serveripaddress:8080/configure",

      And for each of my jobs , i use a groovy post build step which deletes the instance of the docker container after the job finished execution.

      Post build groovy script is as below

      // This script will delete only the currently spawned docker container on vm as well as jenkins web UI
      import jenkins.model.Jenkins

      def x=manager.envVars['NODE_NAME']
      Jenkins.instance.slaves.each {
          if(it.name==x){
             it.getComputer().doDoDelete()
          }
      }

       

      Also have "Email notification" configured for each job . All the above job configurations were working smoothly -

      1) Post build groovy script was deleting currently spawned container allocated to the job

      2) Email notification was working wonderfully.

      All this was working smoothly on jenkins ver 2.1 , however post upgrading my jenkins to 2.62 and other default plugins upgrade which was suggested by default on the dashboard.

      Am getting  below errors for all the jobs :

      ERROR: Step ?E-mail Notification? failed: no workspace for job-name #build-num

      If i comment out the "post build action" - Groovy post build above , then the job passes successfully and email notification works wonderfully.

      Has anyone faced such error ( ERROR: Step ?E-mail Notification? failed: no workspace for job-name #build-num ) post upgrading Jenkins to 2.62 or by just upgrading the Groovy plugin to 2.0 help resolve this issue

      Job Build log error is below
      Started by user
      xxxxxxx
      Building remotely on
      xxxxxxxxx
      (xxxxxxxxxx) in workspace /home/jenkins/workspace/000_AAA_TEMPLATE
      [000_AAA_TEMPLATE] $ /bin/bash /tmp/jenkins356349421822671799.sh
      ERROR: Step ?E-mail Notification? failed: no workspace for 000_AAA_TEMPLATE #432
      Finished: FAILURE
      Whereas the jenkins.log shows below

      INFO: 000_AAA_TEMPLATE #432 main build action completed: SUCCESS
      INFO: Unable to identify the slave of 000_AAA_TEMPLATE #432 (class hudson.model.FreeStyleBuild)

       

      Any comments/thoughts on this would be helpful.

       

       

          [JENKINS-44488] Free style projects/jobs not sending email notification if removed the slave with post build action groovy script enabled

          Just to add that after my jenkins server upgrade to 2.62 , am getting a warning message as attached about upgrading SSH slave plugin version. Currently i have 1.11 version whereas its prompting me to upgrade it to 1.17. Am skeptical about upgrading this plugin , Let me know of pointers to negate the email notification error.

          Amitkumar Ghatwal added a comment - Just to add that after my jenkins server upgrade to 2.62 , am getting a warning message as attached about upgrading SSH slave plugin version. Currently i have 1.11 version whereas its prompting me to upgrade it to 1.17. Am skeptical about upgrading this plugin , Let me know of pointers to negate the email notification error.

          Adding more jenkins logs ...

           

          // code placeholder
          
           INFO: 000_AAA_TEMPLATE #442 main build action completed: SUCCESS
          May 26, 2017 6:38:32 AM org.jenkinsci.plugins.mailwatcher.NodeAwailabilityListener onFinalized
          INFO: Unable to identify the slave of 000_AAA_TEMPLATE #442 (class hudson.model.FreeStyleBuild)
          java.lang.Exception
                  at org.jenkinsci.plugins.mailwatcher.NodeAwailabilityListener.onFinalized(NodeAwailabilityListener.java:95)
                  at hudson.model.listeners.RunListener.fireFinalized(RunListener.java:257)
                  at hudson.model.Run.onEndBuilding(Run.java:1915)
                  at hudson.model.Run.execute(Run.java:1804)
                  at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
                  at hudson.model.ResourceController.execute(ResourceController.java:97)
                  at hudson.model.Executor.run(Executor.java:415)
          

          Amitkumar Ghatwal added a comment - Adding more jenkins logs ...   // code placeholder  INFO: 000_AAA_TEMPLATE #442 main build action completed: SUCCESS May 26, 2017 6:38:32 AM org.jenkinsci.plugins.mailwatcher.NodeAwailabilityListener onFinalized INFO: Unable to identify the slave of 000_AAA_TEMPLATE #442 ( class hudson.model.FreeStyleBuild) java.lang.Exception         at org.jenkinsci.plugins.mailwatcher.NodeAwailabilityListener.onFinalized(NodeAwailabilityListener.java:95)         at hudson.model.listeners.RunListener.fireFinalized(RunListener.java:257)         at hudson.model.Run.onEndBuilding(Run.java:1915)         at hudson.model.Run.execute(Run.java:1804)         at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)         at hudson.model.ResourceController.execute(ResourceController.java:97)         at hudson.model.Executor.run(Executor.java:415)

          Hi All,

          Was able to resolve the issue by just swapping the post build actions : Groovy post build and email notification.

           

          Now my job post build actions order are this way ...

          1. Email notifications
          2. Groovy Post build action

          wondering why just the ordering of post build actions resolves this ...Think this is a bug , which was not present in earlier version : v2.1

           
          Started by user
          xxxxxxxxxxxxxxxx
          Building remotely on
          xxxxxxxxxxxxxx
          (DockerCloud_Ubuntu16.04_Node_JenkinsUser) in workspace /home/jenkins/workspace/000_AAA_TEMPLATE
          [000_AAA_TEMPLATE] $ /bin/bash /tmp/jenkins3037067866040349526.sh
          Finished: SUCCESS

          Amitkumar Ghatwal added a comment - Hi All, Was able to resolve the issue by just swapping the post build actions : Groovy post build and email notification.   Now my job post build actions order are this way ... Email notifications Groovy Post build action wondering why just the ordering of post build actions resolves this ...Think this is a bug , which was not present in earlier version : v2.1   Started by user xxxxxxxxxxxxxxxx Building remotely on xxxxxxxxxxxxxx (DockerCloud_Ubuntu16.04_Node_JenkinsUser) in workspace /home/jenkins/workspace/000_AAA_TEMPLATE [000_AAA_TEMPLATE] $ /bin/bash /tmp/jenkins3037067866040349526.sh Finished: SUCCESS

          ikedam added a comment -

          Removed groovy-postbuild from component/s as there's nothing groovy-postbuild can do for this issue.

          ikedam added a comment - Removed groovy-postbuild from component/s as there's nothing groovy-postbuild can do for this issue.

          ikedam : Thanks for the response .Could you please help verify if this indeed is an issue , has anyone seen such issues earlier ?

          Amitkumar Ghatwal added a comment - ikedam : Thanks for the response .Could you please help verify if this indeed is an issue , has anyone seen such issues earlier ?

          ikedam added a comment -

          amitkumar_ghatwal

          I don't think this is a bug, as Jenkins core requires the workspace to execute steps.
          Rather I think the issue is that Jenkins doesn't protect deleting slaves during builds run on them.
          And I don't know why it worked with Jenkins 2.1.

          Some notes:

          • "E-mail Notification" is not email-ext plugin but mailer-plugin.
          • Who outputs "no workspace for" is Jenkins core, and this is an issue of core.

          ikedam added a comment - amitkumar_ghatwal I don't think this is a bug, as Jenkins core requires the workspace to execute steps. Rather I think the issue is that Jenkins doesn't protect deleting slaves during builds run on them. And I don't know why it worked with Jenkins 2.1. Some notes: "E-mail Notification" is not email-ext plugin but mailer-plugin. Who outputs "no workspace for" is Jenkins core, and this is an issue of core.

          ikedam - Have updated the components to include only "core" for now. Hopefully someone will take a look at this and comment. I think this issue can be resolved by simply ensuring that the post build actions order is such that we send emails first followed by groovy actions .

          Amitkumar Ghatwal added a comment - ikedam - Have updated the components to include only "core" for now. Hopefully someone will take a look at this and comment. I think this issue can be resolved by simply ensuring that the post build actions order is such that we send emails first followed by groovy actions .

            davidvanlaatum David van Laatum
            amitkumar_ghatwal Amitkumar Ghatwal
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: