Due to some maintenance issues, this service has been switched in read-only mode, you can find more information about the why

and how to migrate your plugin documentation in this blogpost

Skip to end of metadata
Go to start of metadata

Plugin Information

View Post build task on the plugin site for more information.

This plugin allows the user to execute a shell/batch task depending on the build log output. Java regular expression are allowed.

This feature allows user to associate shell or a batch scripts that perform some tasks on Hudson depending on the build log output. If the log text has a match some where in the build log file, the script will execute and the post build log will append to the project build log. Java regular expression are allowed.


When you install this plugin, your project configuration page gets additional "Post build task" option as illustrated below:

The Post build task consists of log texts and a script.For the multiple searches, log texts could be joined by an 'And' or an 'Or'. For example, if text "BUILD FAILED" OR "IOException" is found, then it runs the command. For multiple search click on the add button will create one option box (And & Or) and a new log text box.

If the log text has a match it is considered as true otherwise false. Do a bitwise operation for the total match results and if the bitwise result is true, the script will execute otherwise skip


'BUILD FAILED' OR 'IOException' AND 'Building remotely'
'BUILD FAILED' matches so --> 'true'
'IOException' does not match so --> 'false'
'Building remotely' matches so --> 'true'
((true OR false) AND true) --> 'true' (does execute)


'BUILD FAILED' AND 'IOException' AND 'Building remotely'
'BUILD FAILED' matches so --> 'true'
'IOException' does not match so --> 'false'
'Building remotely' matches so --> 'true'
((true AND false) AND true) --> 'false' (does not execute)

Java Regex are allowed for matching log text. If the text is "Total time: (\d+)" and the script is "script.sh", then if the log contains a line "Total time: 10", the "script.sh 10" will be called.

Specify the shell script to be executed when the execution of the task is selected. This is where the actual work happens. When the script executes, the current directory will be the workspace directory, just like the shell script builder. So depending on your SCM, you might have to cd into a directory. Try "pwd" and "ls" to find out whether you need that or not.

Post build task plugin


Version 1.8 (2011/01/03)

  • New option to run script only if all previous steps were successful.
  • New option to fail the whole build if the script execution fails.

Version 1.7 (2010/06/03)

  • Added Spanish translation

Version 1.5 (2009/09/15)

  • Added multiple searches for log text.they could be joined by an 'And' or an 'Or'.
  • Removed grouping for the time being.

Version 1.3 (2009/09/07)

  • Added regex option for log text

Version 1.1 (2009/08/26)

  • Initial version


  1. Unknown User (abelous@hotrmail.com)

    Is it possible to add   environment variables to this plug-in ?
    It will be useful if BUILD_ID, JOB_NAME and other variables will be available to use

    1. Unknown User (horschl)

      any changes here?

  2. Unknown User (tech.release@buongiorno.com)

    We have 3 Hudson running: Master (only web interface) Slave1 & Slave2 for scheduling. I'm afraid that the workspace for "post build task" plugin is on Master, isn't it? I'm asking if it's possible to run "post build task" (like rsync command) on the slave that run the job. Thanks

    1. Unknown User (shinodkm)

      "post build task" plugin run the command on the machine where the job is running. if the job is running on the node(slave)the command will be executed on the node.

      1. Unknown User (tech.release@buongiorno.com)

        You are right :D ... doing more deep tests I find that "post build task" plugin does not access to variable defined into Global properties / Environment variables.I use a command $root_rsync defined as "Environment variable" (to reuse it on many jobs defining rsync pathname only once)

        root_rsync = /opt/hudson-rsync/scripts/noname.rsync

        Can be this my problem?

        1. Unknown User (tech.release@buongiorno.com)

          let me to confirm that I replicate same key/value pari into any slave configurations

          1. Unknown User (shinodkm)

            i will do the necessary changes to add the env variable to this plugin.
            right now it wont take the env variable.

            1. Unknown User (tech.release@buongiorno.com)

  3. Unknown User (tmoreira2020)

    Hi there,

    The replace operation of the regexp groups is not working. Seems that the code that makes the replace is commented out. Can you confirm this?

    1. Unknown User (tomisom)

      I have the same question as Thiago. The Regex matching seems to be currently commented out. Do you have any idea when this feature will be active? It's the reason I wanted to use this plugin.


  4. Unknown User (boakley)

    I can successfully use this plugin for some jobs, but one in particular is giving me an NPE:

    ERROR: Publisher hudson.plugins.build_publisher.BuildPublisher aborted due to exception
    	at hudson.plugins.build_publisher.BuildPublisher.getServerName(BuildPublisher.java:211)
    	at hudson.plugins.build_publisher.BuildPublisher.perform(BuildPublisher.java:61)
    	at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36)
    	at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:600)
    	at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:580)
    	at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:558)
    	at hudson.model.Build$RunnerImpl.cleanUp(Build.java:167)
    	at hudson.model.Run.run(Run.java:1286)
    	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    	at hudson.model.ResourceController.execute(ResourceController.java:88)
    	at hudson.model.Executor.run(Executor.java:122)
  5. Unknown User (ntroncos)

    Is it possible to negate the matching text?

    The thing is that i don't want the post build script to run if the build has been aborted. Any way to do this?

    1. Unknown User (may.a.large.rm44@statefarm.com)

      I have the same requirement as Nicolas. Is there anyway to do this. I tried negating my input Java regex -- but didnt go very far.

      It would be really nice to have a NOT operation on matching the input text.

      1. Unknown User (pedro_larva)

        I have the same requirement, and i try to alter code, but i not understanding the logic of this code.

      2. Unknown User (pedro_larva)

        I have the same requirement, and i try to alter code, but i not understanding the logic of this code.

  6. Unknown User (jcarsique)


    There is no "postbuild-task" component in Jira for Issue Tracking.

    When the post build task fails, there's a log in the console but the build is still marked as success. It would be nice to mark it as failed or unstable:POST BUILD TASK : FAILURE
    Finished: SUCCESS

    1. Unknown User (kristo33)


      I have the same problem. I created a simple job to test this functionality which just write "SUCCESS".

      But when I test with the plugin another string the job is still SUCESS

      + ./test.sh
      Performing Post build task...
      Could not match :SUCCESS1  : False
      Logical operation result is FALSE
      Skipping script  : cd utilities/packaging

      END OF POST BUILD TASK     : 0
      Finished: SUCCESS

  7. Unknown User (s_nemetz)

    Any chance this could be enhanced to launch any build step, instead of just a shell script?

    I have some cases where I need to launch other jobs based on conditions the first job would know.

    Example: job_update_data run job_deploy_data only if new data was received

  8. Unknown User (cthayer@sensorlogic.com)

    Can you make the 1.8 version default to "run script only if all previous steps were successful?"  When I upgraded from 1.7 to 1.8 the new version added the two new selection boxes, as stated in your release notes above, however both boxes were defaulted to unchecked.  This resulted in a the following error when I ran one of our Hudson jobs:

    Match found for :BUILD SUCCESSFUL : True
    Logical operation result is TRUE
    Exception when executing the batch command : null
    Finished: FAILURE

    When I edited the Hudson job and selected the "run script only if all previous steps were successful" box, the post-build script ran as it normally did before the upgrade.

    I realize the previous plugin version (1.7) relied on the user doing something kludgy like reading the log file for something like "BUILD SUCCESSFUL" to determine if the post-build script should be run, but I believe most users want the the post-build script to run upon successful completion of the Hudson job tasks.

    Anyway my point is that by defaulting both boxes to unchecked, but requiring at least one of the options to be checked (which, in our case, would require hundreds of configuration file edits) in order for the plugin not to cause the Hudson job to exit with a failure status, seems short-sighted and/or unreasonable.

    I chose to back the 1.8 plugin upgrade out of Hudson rather than having to edit hundreds of Hudson job configuration files.

  9. Unknown User (tgsoverly)

    In the latest version of the plugin (1.8).  I am getting saving issues when I have more than one build task.  The situation is I want to send notifications to a wall that we have our build statuses.  So I want one script to execute if the successful box is checked and one to execute with the box unchecked.  The issue is that the plugin doesn't save the extra build steps unless both the check boxes are checked.  I will create the steps, save the configuration, then return to the configuration and all (or more) of the steps without unchecked boxes are gone.  I am using Jenkins 1.432

  10. Unknown User (dannox)

    Is it possible to force the failure of the dashboard, considering the log.txt of the step?

  11. Unknown User (jspang)

    I have a post build task that looks for "BUILD FAILED" and runs a script. Sometime in the last couple weeks, this stopped working and I can't figure out why. Here is what it says:

    12:28:16  Performing Post build task...
    12:28:16  Match found for :BUILD FAILED : True
    12:28:16  Logical operation result is TRUE
    12:28:16  Skipping post build task 0 - job status is worse than unstable : FAILURE

    Anyone know why Jenkins is doing this now, and how we can get it to run the post build task again?

  12. Unknown User (pndurette)

    Hello guys,

    First of all thanks for a great plugin. Second, I'm wondering how time consuming it would be for you guys to replace/add 'Script' with the possibility to select (one or more) 'Build Steps'?

    Our use case: In our current setup, our build nodes are Windows (.NET build) with Cygwin so we can execute Shell scripts on them. With most plugins, we can select the 'Execute shell' Build Step to do this, but the 'Script' field of the Post Build Task plugin will execute natively on whatever the build node is. We then get cmd instead of bash.


  13. Unknown User (ryg_)

    I prepared patch for adopting postbuild-task plugin for matrix task. HowI can pass review and  put to main branch?

  14. Unknown User (kevinchow)

    Is it possible, let's say if "Build ABC success" is not showed in log, I could execute a script like to FAILING this build?

    Tasks > Log Text (I'm trying to figure out if it would work with.)

    Thanks for any input.

  15. Unknown User (willou)

    I'm trying to run a post build task script in every possible cases of build state (success, failed, abort).

    case success / failed : works fine

    case abort :  [workspace] $ cmd /c call C:\Users\XXXX\AppData\Local\Temp\2\hudson13287273761205392.bat
    Exception when executing the batch command : null
    Build step 'Post build task' marked build as failure

    C:\Users\XXXX\AppData\Local\Temp\2\ is the value of java.io.tmpdir

    It appears that the temp bat file is never written in the folder (I ran an infinite loop bat script that listed the folder files during the job execution and abortion).

    In order to avoid eventual root cause i'm trying just to run a "dir" command

    As a job abort provokes a JAVA interruptedException, does jenkins can achieve to get java.io.tmpdir and write in the folder? Maybe a lock issue?

    However it is impossible for me to run a post build task when the build has been stopped manually or by a timeout setting.

    Is this an improvement? a bug? or a config issue from myself?

  16. Unknown User (anil_rapani)

    I also need to execute a script if string(UNSTABLE) is not found in all the log files

    Pls post any java regex script for this.

    There is no UNSTABLE keyword in any of the log files of mine So below must below must be "true" and the script should run as you said java regex is accept. But why is this false

    I tried this ^(?!.(UNSTABLE)).$ but not working....

    Below is my build result:

    Could not match :^(?!.(UNSTABLE)).$ : False

    Logical operation result is FALSE
    Skipping script : php -f /home/devblaze/NetBeansProjects/eick494/dbmigration/customers.php;
    Finished: SUCCESS