• Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major Major
    • None
    • Jenkins 2.107.3
      Server OS: CentOS 7
      Build Node OS: Windows / CentOS / Ubuntu
      Job Type: Matrix

      In all our jobs, we have a pre-build section (part of which is mounting a drive), a build section, and a post-build section (part of which is umounting the drive, mounted from prebuild).

      Any time the pre-build section fails - for any reason, the post build section also fails.

      Simple build log from a job I created to reproduce this:

      [EnvInject] - Loading node environment variables.
      [EnvInject] - Preparing an environment for the build.
      [EnvInject] - Could not resolve custom child workspace, reverting to default location: f95dd186
      [EnvInject] - Keeping Jenkins system variables.
      [EnvInject] - Keeping Jenkins build variables.
      [EnvInject] - Executing and processing the following script content: 
      #!bash
      set +v
      echo "Running pre-build..."
      echo "Pretending to do things, and stuff..."
      sleep 10
      if [ "${NODE_NAME}" = "matrix-parent-node" ]
      then
      echo "Setting exit code to 0"
      exit 0
      else
      echo "Setting exit code to 100"
      exit 100
      fi
      
      [/jenkins] $ bash /tmp/jenkins3631444041177859652.sh
      Running pre-build...
      Pretending to do things, and stuff...
      Setting exit code to 100
      [EnvInject] - Script executed. The exit code is 100.
      [EnvInject] - Fail the build.
      ERROR: Build step failed with exception
      java.lang.NullPointerException
      	at org.jenkinsci.plugins.postbuildscript.processor.Processor.<init>(Processor.java:50)
      	at org.jenkinsci.plugins.postbuildscript.processor.ProcessorFactory.createDefaultProcessor(ProcessorFactory.java:24)
      	at org.jenkinsci.plugins.postbuildscript.processor.ProcessorFactory.createMatrixProcessor(ProcessorFactory.java:35)
      	at org.jenkinsci.plugins.postbuildscript.MatrixPostBuildScript.perform(MatrixPostBuildScript.java:68)
      	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
      	at hudson.model.Build$BuildExecution.post2(Build.java:186)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
      	at hudson.model.Run.execute(Run.java:1752)
      	at hudson.matrix.MatrixRun.run(MatrixRun.java:146)
      	at hudson.model.ResourceController.execute(ResourceController.java:97)
      	at hudson.model.Executor.run(Executor.java:429)
      Build step 'Execute Scripts on Matrix' marked build as failure
      Collecting metadata...
      Metadata collection done.
      Finished: FAILURE

      In our post-build actions, we have a step Execute Scripts on Matrix, that is supposed to run regardless of the build result (success, unstable, failure, not-built, and aborted, are all selected).

      It is also supposed to run on both the master and slave. The "Matrix Target" setting in the plugin is set to both.

       

          [JENKINS-52018] Post build script fails, when pre-build script fails.

          FYI: I also tried this with version 2.7.0

          Sagar Khushalani added a comment - FYI: I also tried this with version 2.7.0

          Daniel Heid added a comment -

          Hi Sagar,

          I tried to reproduce this problem on my single node using the label "master" and there was no NullPointerException. I guess it has something to do with the slave. Which OS is installed on the MATRIX_PARENT? Is it the same machine? What machine is LINUX_BUILD? A screenshot of your nodes overview would be very helpful.

          Regards

          Daniel

          Daniel Heid added a comment - Hi Sagar, I tried to reproduce this problem on my single node using the label "master" and there was no NullPointerException. I guess it has something to do with the slave. Which OS is installed on the MATRIX_PARENT? Is it the same machine? What machine is LINUX_BUILD? A screenshot of your nodes overview would be very helpful. Regards Daniel

          Hey Daniel

          I assume both parent and configuration jobs ran on the same node? Can you try it with a different nodes, or at least executors (so that the workspace is different)?

          The MATRIX_PARENT is CentOS 7. Same for the LINUX_BUILD machine. They are different nodes.

          I've attached an Excel sheet with the node's environment variables and system properties.

          Sagar Khushalani added a comment - Hey Daniel I assume both parent and configuration jobs ran on the same node? Can you try it with a different nodes, or at least executors (so that the workspace is different)? The MATRIX_PARENT is CentOS 7 . Same for the LINUX_BUILD machine. They are different nodes. I've attached an Excel sheet with the node's environment variables and system properties.

          Daniel Heid added a comment -

          Still cannot reproduce. Thanks for the attachment, but I just wanted to know the setup of your nodes: Are MATRIX_PARENT and LINUX_BUILD nodes or the master?

          Daniel Heid added a comment - Still cannot reproduce. Thanks for the attachment, but I just wanted to know the setup of your nodes: Are MATRIX_PARENT and LINUX_BUILD nodes or the master?

          Ah, oops.

          MATIRX_PARENT and LINUX_BUILD are both nodes. MATRIX_PARENT is a static node that is used specifically for matrix parent jobs. LINUX_BUILD is the label for a set of cloud nodes, created on demand as builds require them.

          Sagar Khushalani added a comment - Ah, oops. MATIRX_PARENT and LINUX_BUILD are both nodes. MATRIX_PARENT is a static node that is used specifically for matrix parent jobs. LINUX_BUILD is the label for a set of cloud nodes, created on demand as builds require them.

          Daniel Heid added a comment -

          I found out, that the PostBuildScript plugin will not be triggered, if you use the flag "Prepare an environment for the run". Please try instead "Inject environment variables to the build process" in the section "Build Environment". Will the problem still exist?

          Daniel Heid added a comment - I found out, that the PostBuildScript plugin will not be triggered, if you use the flag "Prepare an environment for the run". Please try instead "Inject environment variables to the build process" in the section "Build Environment". Will the problem still exist?

          That worked, no errors.

          Is there a way to get the plugin to be triggered with the "Prepare an environment for the run" option, or do we know why it won't?

          Sagar Khushalani added a comment - That worked, no errors. Is there a way to get the plugin to be triggered with the "Prepare an environment for the run" option, or do we know why it won't?

          Daniel Heid added a comment -

          Sorry, I do not have the time to investigate, why the other option does not work. I will close this ticket now.

          Daniel Heid added a comment - Sorry, I do not have the time to investigate, why the other option does not work. I will close this ticket now.

            dheid Daniel Heid
            skhushalani Sagar Khushalani
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: