Post build task

Plugin Information

Plugin ID postbuild-task
Latest Release 1.8
Latest Release Date Jan 03, 2011
Sources Subversion
Support Eclipse Hudson Forum
Issue Tracking Eclipse Bugzilla

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: 12", the "script.sh 12" 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
plugn-builder plugn-builder Delete
tier3-hudson-plugin tier3-hudson-plugin Delete
Enter labels to add to this page:
Wait Image 
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

      Shinod Mohandas 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

            Shinod Mohandas 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?

  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.

  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

  7. Feb 24, 2011

    Hubert says:

    I'm currently playing with the "Script" portion of it, and I want to use the Ref...

    I'm currently playing with the "Script" portion of it, and I want to use the References %1, %2, ... %n to be able to place the matched regex groupings into the appropriate arguments for a script.

    However, the syntax does not seem to work for me.

    An example is just doing this:

    My regex is: "Value=(\d+)"

    The match is successful because I see in the Hudson logs:
    Match found for Value=(\d+)
    Logical operation result is TRUE

    Yet, when the script field runs:
    echo %1 %0

    It just outputs the exact text "echo %1 %0".

    Am I using the references incorrectly?

    1. Jun 16, 2011

      Tatyana Tvardovskaya (aka salmira) says:

      The same problem when trying to use match results in the script file: neither %0...

      The same problem when trying to use match results in the script file: neither %0 %1 ... nor \0 \1 (as in Set Description plugin) work.

      Script file script.sh:
      echo 'group 0: %0 \0'; echo 'group 1: %1 \1'
      echo group 0: %0 \0; echo group 1: %1 \1

      The match is successful:
      01:36:40 Match found for :Value=(\d+): True
      01:36:40 Logical operation result is TRUE
      01:36:40 Running script : script.sh
      01:36:40 [set_description] $ /bin/bash -xe /tmp/hudson4669165965898173298.sh
      01:36:40 + script.sh
      01:36:40 group 0: %0 \0
      01:36:40 group 1: %1 \1
      01:36:40 group 0: %0 0
      01:36:40 group 1: %1 1

      How to use "References %1, .. %n are allowed" correctly? Is there some bug?

      1. Jan 12, 2012

        Charles Liu Z says:

        Now I encounter the same block as you did. All I want to know is that how hudson...

        Now I encounter the same block as you did. All I want to know is that how hudson pass value resulting from matching with log to script. Have you resolve this problem? If so, pls help me out.

  8. Mar 09, 2011

    Jeff Foege says:

    The post build plugin seems to be working great. The only problem I have is eith...

    The post build plugin seems to be working great. The only problem I have is either the plugin or Hudson is running the post build step before the unit tests are published.

    After our builds we run some junit tests on the build and based on these tests I would like to do the post build step. If the build fails for what ever reason I don't want the post-build step to run. I've included the last part of a build log to help explain.

    [ PASSED ] 134 tests.

    C:{project_path}>exit 0
    Recording test results
    Performing Post build task...
    Match found for :Build succeeded : True
    Logical operation result is TRUE
    Running script : call %WORKSPACE%\Algorithm\Build\PC\Post-Build.bat
    [workspace] $ cmd /c call C:\apache-tomcat-7.0.8\temp\hudson8192375492316114977.bat

    C:\.hudson\jobs\RR-V1_0_Iter1\workspace>call C:\.hudson\jobs\RR-V1_0_Iter1\workspace\Algorithm\Build\PC\Post-Build.bat

    C:\.hudson\jobs\RR-V1_0_Iter1\workspace>echo "script for post build steps"

    C:\.hudson\jobs\RR-V1_0_Iter1\workspace>set PWD=C:\.hudson\jobs\RR-V1_0_Iter1\workspace\Algorithm\Build\PC\

    C:\.hudson\jobs\RR-V1_0_Iter1\workspace>echo C:\.hudson\jobs\RR-V1_0_Iter1\workspace\Algorithm\Build\PC\
    C:\.hudson\jobs\RR-V1_0_Iter1\workspace\Algorithm\Build\PC\

    C:\.hudson\jobs\RR-V1_0_Iter1\workspace>exit 0
    POST BUILD TASK : SUCCESS
    END OF POST BUILD TASK : 0
    Finished: SUCCESS

    Here is example of a build without a post build step and with a status of unstable.
    [ PASSED ] 134 tests.

    C:\.hudson\jobs\RR-Iter1\workspace\Algorithm\Test\UnitTest\Debug>exit 0
    Recording test results
    Finished: UNSTABLE

    I would like to run the post-build step based on what Finished says since that will have the status of the build.

  9. Jan 12, 2012

    Charles Liu Z says:

    Could anyone help to fix Hubert's and my question, pls? Thanks in advance.

    Could anyone help to fix Hubert's and my question, pls?

    Thanks in advance.