Post build task

Skip to end of metadata
Go to start of metadata

Plugin Information

Plugin ID postbuild-task Changes In Latest Release
Since Latest Release
Latest Release
Latest Release Date
Required Core
Dependencies
1.8
Jan 03, 2011
1.357
Source Code
Issue Tracking
Maintainer(s)
Subversion
Open Issues
Shinod Mohandas (id: shinodkm)
Fred (id: castorpilot)
Usage Installations 2013-Apr 5501
2013-May 5619
2013-Jun 5816
2013-Jul 6101
2013-Aug 6153
2013-Sep 6272
2013-Oct 6679
2013-Nov 6680
2013-Dec 6647
2014-Jan 7073
2014-Feb 7305
2014-Mar 7626

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.

Usage

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

Example:1

'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)

Example:2

'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

Changelog

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

Labels

plugin-post-build plugin-post-build Delete
plugin-builder plugin-builder Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Oct 26, 2009

    Andrey says:

    Is it possible to add   environment variables to this plug-in ? It wil...

    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. Apr 13, 2010

      Horst Scholl says:

      any changes here?

      any changes here?

  2. Mar 25, 2010

    Tech Release says:

    We have 3 Hudson running: Master (only web interface) Slave1 & Slave2 for sc...

    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. Mar 25, 2010

      shinodkm - says:

      "post build task" plugin run the command on the machine where the job is running...

      "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. Mar 25, 2010

        Tech Release says:

        You are right :D ... doing more deep tests I find that "post build task" plugin ...

        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. Mar 25, 2010

          Tech Release says:

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

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

          1. Mar 25, 2010

            shinodkm - says:

            i will do the necessary changes to add the env variable to this plugin. right no...

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

            1. Mar 25, 2010

              Tech Release says:

              Great!

              Great!

  3. Jun 24, 2010

    Thiago Leão Moreira says:

    Hi there, The replace operation of the regexp groups is not working. Seems that...

    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. Nov 02, 2012

      Tom Sommerville says:

      I have the same question as Thiago. The Regex matching seems to be currently com...

      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.

      Thanks!

  4. Aug 10, 2010

    Bryan Oakley says:

    I can successfully use this plugin for some jobs, but one in particular is givin...

    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
    java.lang.NullPointerException
    	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. Oct 06, 2010

    Nicolas Troncoso says:

    Is it possible to negate the matching text? The thing is that i don't want the ...

    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. Oct 20, 2010

      May says:

      I have the same requirement as Nicolas. Is there anyway to do this. I tried nega...

      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. Dec 12

        Pedro Leite says:

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

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

      2. Dec 12

        Pedro Leite says:

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

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

  6. Oct 11, 2010

    Julien Carsique says:

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

    Hello,

    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
    END OF POST BUILD TASK : 0
    Finished: SUCCESS

    1. Nov 21

      cussaguet christophe says:

      Hello, I have the same problem. I created a simple job to test this functionali...

      Hello,

      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
      SUCCESS
      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. Mar 30, 2011

    Steven Nemetz says:

    Any chance this could be enhanced to launch any build step, instead of just a sh...

    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. Sep 08, 2011

    Craig Thayer says:

    Can you make the 1.8 version default to "run script only if all previous steps w...

    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. Oct 04, 2011

    Timothy Overly says:

    In the latest version of the plugin (1.8).  I am getting saving issues when...

    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. Mar 06, 2012

    daniele giunchi says:

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

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

  11. Apr 17, 2012

    Jay Spang says:

    I have a post build task that looks for "BUILD FAILED" and runs a script. Someti...

    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. Mar 18, 2013

    Pierre-Nick Durette says:

    Hello guys, First of all thanks for a great plugin. Second, I'm wondering how t...

    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.

    Thanks!

  13. Jul 01, 2013

    Roman G says:

    I prepared patch for adopting postbuild-task plugin for matrix task. HowI can pa...

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

  14. Nov 18

    Kevin Chow says:

    Is it possible, let's say if "Build ABC success" is not showed in log, I could e...

    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.