Batch Task Plugin

Plugin Information

Plugin ID batch-task
Latest Release 1.14
Latest Release Date Nov 11, 2010
Sources Subversion
Support Eclipse Hudson Forum
Issue Tracking Eclipse Bugzilla

This plugin adds batch tasks that are not regularly executed to projects, such as releases, integration, archiving, etc. In this way, anyone in the project team can execute them in a way that leaves a record.

Usage

When you install this plugin, your project configuration page gets additional "batch tasks" option as illustrated below:

A batch task consists of a shell script and a name. When you execute a build, the shell script gets run on the workspace, just like a build. Batch tasks and builds "lock" the workspace, so when one of those activities is in progress, all the others will block in the queue.

Once a task is configured, the project top page gets "task(s)" link, as illustrated below:

If you click that, you can see the status of all the tasks. You can schedule the execution of a task from here, too. Task executions are numbered like "123-456" where 123 portion refers to the latest build and 456 portion refers to the sequential number (so that you can execute a task multiple times with the same build.) The build number portion is significant because when a batch task runs, it sees the workspace as of the result of this build.

The details of the task execution and its console output are available by further clicking a task of the interest, as below:

Change Log

Version 1.14 (Nov 11, 2010) - requires Hudson 1.383+

  • Fixed an AbstractMethodError when running with Hudson 1.383+ (issue #8033)

Version 1.13 (Feb 10, 2010)

  • Use resizable text area for task script. (issue #5578)
  • Apply environment settings from setenv plugin when running tasks. (issue #5580)
  • Show links to downstream tasks on project page. (issue #5582)

Version 1.12 (Feb 5, 2010)

  • Lock workspace during task run to prevent owner project or other tasks from using the same workspace. (issue #5285)
  • Show animated ball icon for Tasks link in sidepanel when a task is running. (issue #3372)

Version 1.11 (Jan 3, 2010)

Version 1.10 (Dec 7, 2009)

  • A few minor bug fixes.

Version 1.9 (Nov 5, 2009)

  • Add "trigger even if build is unstable" selector for invoking tasks as a post-build action. Previously the tasks were always invoked (even for failed builds); now they will only run if the build result meets the required threshold (and never for failed builds).
  • Fix build number written to job log when task is invoked as a post-build action (was off by one)
  • Fix broken image for aborted task (grey ball)
  • On task page, show only builds for this task in Build History (instead of all tasks)
  • Avoid error if try to run a task when there are no builds for the project

Version 1.8 (Aug 28, 2009)

  • Improved the error diagnosis and recovery when a build no longer has a workspace (report) – requires Hudson 1.319 or higher.

Version 1.7 (Mar 31, 2009)

  • Allow non-admin users ability to manage and execute tasks (issue #1198)

Version 1.6 (Feb 27, 2009)

  • Updated to work with recent versions of Hudson (issue #3173)

Version 1.5 (Jan 27, 2009)

  • Fixed a bug "batchtask in queue causes NPE at startup" (issue #2925)

Version 1.3 (Jan 29, 2008)

  • Updated to work with the latest version of Hudson, so that it won't cause AbstractMethodError (report)
  • Last successful/failed builds were computed incorrectly (issue #1012)
  • Icon size in task list is now configurable (issue #1010)

Version 1.2 (Nov 16, 2007)

  • Task can be now individually deleted from the left menu
  • Build number should start from 1 (issue #991)
  • Tasks now work on Windows (issue #985)
  • Build icon in task list is not larger than the other icons (issue #1010)

Version 1.0 (Oct 18, 2007)

  • initial version

Labels:

plugin-post-build plugin-post-build Delete
plugin-builder plugin-builder Delete
tier3-hudson tier3-hudson 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. Jul 24, 2008

    fabrice says:

    Ok nice but only admin role can execute batch task ! So it is not anyone. ...

    Ok nice but only admin role can execute batch task ! So it is not anyone.

    Should I opened a issue on jira ?


  2. Oct 01, 2008

    Wouter Batelaan says:

    I'm confused about this plugin - I don't see its usefulness, since it seems to d...

    I'm confused about this plugin - I don't see its usefulness, since it seems to do what the locks plugin does

    ( http://hudson.gotdns.com/wiki/display/HUDSON/Locks+and+Latches+plugin ).

    And the tasks it allows to create are less flexible than the tasks in a normal job.

    How do the batch plugin tasks relate to the normal tasks that a job performs?

    Do they run before, after, or in paralel?

    1. Oct 01, 2008

      Purnank Harjivanbhai Ghumalia says:

      Hi Wouter, This plug-in allows to have jobs to be executed in isolation! It he...

      Hi Wouter,

      This plug-in allows to have jobs to be executed in isolation!
      It helps for the jobs that are not executed very frequently, or at-least not nightly!

      The jobs are just a "click" away!

      --PG

  3. Jan 23, 2009

    James Brook says:

    Is it possible to use this plugin to execute tasks against builds that are not t...

    Is it possible to use this plugin to execute tasks against builds that are not the latest build? It would seem useful to be able to select a build from the build history and then have a 'tasks' link to run tasks for that particular build, for example a 'release/deploy' task. You don't always want to deploy the most recent build. --James

  4. Feb 22, 2009

    Shibu Gope says:

    This plugin is causing Hudson (v1.285) to crash with the following exception: ja...

    This plugin is causing Hudson (v1.285) to crash with the following exception:
    javax.servlet.ServletException: org.apache.commons.jelly.JellyTagException: jar:file:/ACN/app/jboss/server/ci/tmp/deploy/tmp41576hudson-exp.war/WEB-INF/lib/hudson-core-1.285.jar!/lib/hudson/queue.jelly:60:62: <j:set> java.lang.IncompatibleClassChangeError
    org.kohsuke.stapler.jelly.JellyClassTearOff.serveIndexJelly(JellyClassTearOff.java:48)
    org.kohsuke.stapler.jelly.JellyFacet.handleIndexRequest(JellyFacet.java:70)
    org.kohsuke.stapler.Stapler.invoke(Stapler.java:427)
    org.kohsuke.stapler.Stapler.invoke(Stapler.java:459)
    org.kohsuke.stapler.Stapler.invoke(Stapler.java:356)
    org.kohsuke.stapler.Stapler.service(Stapler.java:116)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      ...

  5. Aug 07, 2009

    Jim Patterson says:

    Here is an idea for enhancement of this plugin: Make the batch tasks plugin ...

    Here is an idea for enhancement of this plugin: Make the batch tasks plugin have the same functionality as the "This build is parameterized" checkbox in the configuration page of the projects. It would be best if each individual task had its own per task "This task is parameterized" checkbox. However it would still be helpful if there was a single "These tasks are parameterized" checkbox for all the tasks to share. In either case, when a parameterized task is executed, the parameters would asked for and the values of the parameters would be setup as environment variables that are available for the tasks to use. With this functionality, tasks could be written to do almost anything to the workspace independent of the last build of the project.

    1. Sep 04, 2009

      Adam Armistead says:

      I totally second this idea.  This would be quite helpful.  I am lookin...

      I totally second this idea.  This would be quite helpful.  I am looking for a way to deploy my project and prompt for the software version number for the deployment, and this idea would fit that nicely.

      1. Jul 12, 2010

        Kalpesh Soni says:

        +1 for paramerterizing batch builds koshuke where are thou?

        +1 for paramerterizing batch builds

        koshuke where are thou?

  6. Nov 10, 2009

    Ben J Warner says:

    When a user kicks off a task, it would be great to have their username available...

    When a user kicks off a task, it would be great to have their username available in an environment variable.  I've used the tasks plugin to trigger all our deployment tasks.  We record in a database who did each deployment, so at the moment user the tasks plugin, the "user" is an unknown.  This is raised as issue #1628, but just thought I'd vote for it here as well. 

  7. Nov 12, 2009

    Christian Schneider says:

    First, this plugin is great! What I miss a bit is: global environment prope...

    First, this plugin is great!

    What I miss a bit is: global environment properties (set in Hudson main configuration) are not available to the batch task. But that's not a crucial issue for me. More a nice-to-have.

    Christian

  8. Dec 09, 2009

    James Clinton says:

    Great plugin. Thanks. Feature request: It would be great if the task history c...

    Great plugin. Thanks.

    Feature request:

    It would be great if the task history could be visible for a past Job. 

    The tasks history is currently refreshed after building the job, so someway of getting this for a previous job would be useful.

    Hope that's clear.

  9. Dec 15, 2009

    Douglas Borg says:

    This plugin is great! I second James' feature request above, and would like to...

    This plugin is great!

    I second James' feature request above, and would like to add my own:

    Would it be possible to allow batch tasks to run on a scheduled basis?

    Why:
    I have indexing jobs that I would like to run as a batch task for the deployment jobs they are related to. Currently, I have separate jobs in Hudson that check out the same workspace as the deployment job and I would like to avoid this if possible. It would also be nicer if it was a batch task because then I could directly relate the indexing runs to the deployment "build" number and not run the indexing jobs while the deployment job is running. Right now my indexing jobs just fail while the deployment is actually running. I hope this makes sense; please let me know if you have any questions or suggestions for other ways of accomplishing this.

    Also, please let me know if there is a more appropriate place to request features for plugins than the plugin wiki page.

    Thanks again!

  10. Jan 26, 2010

    Hugo Monteiro says:

    Hi there, Thanks for this plugin, it's very useful. I have a feature request a...

    Hi there,

    Thanks for this plugin, it's very useful.

    I have a feature request and a "bug"(?) issue for it:

    1) Bug(?): "Task" Menu should show every time if there are tasks configured and/or tasks defined for execution for the job.
    "Task" Menu isn't shown if there are no tasks configured in the current job, although there are tasks defined for execution (invoke batch tasks) in job's configuration, provided from a different job.

    2) Feature Request: It would be nice that the fields in the job's configuration section "Invoke batch tasks" could be automatically updated when entering a value (mimicking the behavior hudson has when creating a new Job by copying an existing job, when entering values in "copy from field"). Currently, one has to enter the job's name in the "Project field", save the job, and returning to configuration to be able to see all related tasks from the previously specified job.

    Thanks!

  11. Feb 17, 2010

    ndierauf says:

    Any chance that the task name can be exposed as an environment variable? Thanks...

    Any chance that the task name can be exposed as an environment variable?

    Thanks,
    Nick.

  12. May 12, 2010

    Vivek R says:

    Hi, I have some problems with batch tasks, its failing to excute the task Huds...

    Hi,

    I have some problems with batch tasks, its failing to excute the task

    Hudson ver. 1.354 Plugin: 1.13

    Task: echo hello

    [Test-BuildConf] $ cmd /c call C:\WINDOWS\TEMP\hudson25025.bat
    The directory name is invalid
    FATAL: command execution failed
    ha:AAAAWB+LCAAAAAAAAABb85aBtbiIQSmjNKU4P08vOT+vOD8nVc8DzHWtSE4tKMnMz/PLL0ldFVf2c+b/lb5MDAwVRQxSaBqcITRIIQMEMIIUFgAAckCEiWAAAAA=java.io.IOException: Cannot run program "cmd" (in directory "d:\hudson\workspace\Test-BuildConf"): CreateProcess error=267, The directory name is invalid
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
    at hudson.Proc$LocalProc.<init>(Proc.java:149)
    at hudson.Proc$LocalProc.<init>(Proc.java:121)
    at hudson.Launcher$LocalLauncher.launch(Launcher.java:633)
    at hudson.Launcher$ProcStarter.start(Launcher.java:268)
    at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:778)
    at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:754)
    at hudson.remoting.UserRequest.perform(UserRequest.java:114)
    at hudson.remoting.UserRequest.perform(UserRequest.java:48)
    at hudson.remoting.Request$2.run(Request.java:270)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: java.io.IOException: CreateProcess error=267, The directory name is invalid
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
    at java.lang.ProcessImpl.start(ProcessImpl.java:30)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
    ... 15 more

    but it works fine on a different system with same version

    1. Jun 17, 2010

      Daniel Kaplan says:

      I think I have a related problem here. I named my project from "AppName" to "Ap...

      I think I have a related problem here. I named my project from "AppName" to "App Name" but the batch tasks are still trying to execute the script in the old path so it can't find the script.

      Here's the exception:
      [workspace] $ /bin/sh -xe /tmp/hudson3200245917642124053.sh
      FATAL: command execution failed
      ha:AAAAWB+LCAAAAAAAAABb85aBtbiIQSmjNKU4P08vOT+vOD8nVc8DzHWtSE4tKMnMz/PLL0ldFVf2c+b/lb5MDAwVRQxSaBqcITRIIQMEMIIUFgAAckCEiWAAAAA=java.io.IOException: Cannot run program "/bin/sh" (in directory "/opt/hudson/jobs/AppName/workspace"): java.io.IOException: error=2, No such file or directory
      at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
      at hudson.Proc$LocalProc.<init>(Proc.java:149)
      at hudson.Proc$LocalProc.<init>(Proc.java:121)
      at hudson.Launcher$LocalLauncher.launch(Launcher.java:638)
      at hudson.Launcher$ProcStarter.start(Launcher.java:273)
      at hudson.Launcher$ProcStarter.join(Launcher.java:280)
      at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:83)
      at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:58)
      at hudson.plugins.batch_task.BatchRun.run(BatchRun.java:295)
      at hudson.model.ResourceController.execute(ResourceController.java:88)
      at hudson.model.Executor.run(Executor.java:124)
      Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
      at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
      at java.lang.ProcessImpl.start(ProcessImpl.java:65)
      at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
      ... 10 more

  13. Dec 02, 2010

    Robert Gröber says:

    Hi Is it possibe to do a Task before any other operation, also before the SCM p...

    Hi

    Is it possibe to do a Task before any other operation, also before the SCM plugin?

    We're using a svn mirror to checkout, but switching to main repo to do some commits. To use the advantage of updating the working copy, we have to switch back to the main repo. But in a batch task it will only switch on successful and unstable build.

    thanks for your plugin, its very useful for release purposes.

    robert

  14. Dec 19, 2010

    Indra Gunawan says:

    I am trying to setup a job that will invoke batch task of another project in Pos...

    I am trying to setup a job that will invoke batch task of another project in Post-Build Action. How do I pass to batch task (Downstream Tasks) parameters?

    Thank you,
    -Indra

  15. Mar 31, 2011

    developer says:

    Hi, is there a possibility to define a pre-build batch tasks? I have installed ...

    Hi,
    is there a possibility to define a pre-build batch tasks?

    I have installed the latest batch-task plugin 1.4 joining latest hudson version Hudson ver. 1.395.1
    In a maven project I have enable the Batch Tasks ckechbox and defined some batch commands like

    "net stop Tomcat5"
    "RMDIR /Q /S "C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\somedWebApp"
    "net start Tomcat5"

    I can execute the Task manually in the Tasks view but there seem to be no automatically pre or post execution when I run the project?

    Is this a bug of the batch task plugin or do I something wrong.

    In between I played arroung with different Post-build-actions by enabling "Invoke batch tasks" checkbox in the bottom of the project configuration.
    There I have checked the "Trigger even if the build is unstable" option and added all Task which I have defined in the "Batch Task" section in the top of the configuration.
    Nothing helped to execute the batches automatically.

    Any help would be much appreciated

    Thanks
    Workerthread