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

Post build script fails, when pre-build script fails.

XMLWordPrintable

    • 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.

       

        1. config.xml
          9 kB
          Sagar Khushalani
        2. node_overview.xlsx
          12 kB
          Sagar Khushalani

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

              Created:
              Updated:
              Resolved: