Child pages
  • Pre-Post Build Command Plugin
Skip to end of metadata
Go to start of metadata

Name

Pre/Post Build Command Plugin

Version

2.4.0

Product Versions

2.2.x , 2.3.x, 2.4.x

Author(s)

Jonathan Doklovic [developer(at)sysbliss(dot)com]

Homepage

http://blog.sysbliss.com

Price

Free

License

BSD

JavaDocs

 

IssueTracking

http://developer.atlassian.com/jira/browse/BPBC

Subversion URL

https://svn.atlassian.com/svn/public/contrib/bamboo/bamboo-prepostcommand-plugin or browse via fisheye

Download JAR
for bamboo 2.4

prepost-build-command-2.4.0.jar

2.1.x compatible

prepost-build-command-2.2.0.jar

2.2.x compatible

prepost-build-command-2.3.3.jar

2.3 compatible

prepost-build-command-2.3.4.jar

Configuration Change

Since version 2.2.0 all commands pre AND post are configured on the builder screen.
Post commands are no longer on the Post Actions screen.

Description/Features

This plugin can run an arbitrary command before a build runs or when a build passes or fails.
The pre command is specified on the Builder Configuration page.
The post commands are also specified on the Builder Configuration configuration page.
Ability to specify if commands run in the bamboo build thread or in their own spawned thread
Sysout and Syserr from the command are logged to the bamboo.log file.
Sysout and Syserr also go to the build log in the web interface if a pre command runs in the bamboo thread.
since 2.2.0 Ability to specify if commands run on the server or on the agent

Usage

Installation Change

Since version 2.4.0 the plugin should now be installed into BAMBOO_HOME/plugins
Post commands are no longer on the Post Actions screen.

  1. Download and install the plugin into your Bamboo WEB-INF/lib folder (see note above)
  2. Select your build and edit the Builder Configuration under the Configuration tab.
  3. Enter the complete command line to run before the build in the Command field.
  4. Select your build and edit the Builder under the Configuration tab.
  5. Enter the complete command line(s) to run in the Success and Failed Command fields
  6. After each build, the system will run either the Success or Failed command as appropriate if it's filled in

Configuration Details

Each command field will expand ALL global and custom variables including:

property

description

${bamboo.buildKey}

the build key. (i.e. PRJ-PLAN)

${bamboo.buildNumber}

the build number. (i.e. 14)

${bamboo.fullBuildKey}

the full build key. (i.e. PRJ-PLAN-14)

${bamboo.buildResultsUrl}

the build results url

${bamboo.projectBaseDir}

the project base dir (i.e. checkout dir)

Screenshots

Open Issues

type key summary reporter status

Unable to locate Jira server for this macro. It may be due to Application Link configuration.

Version History

2.4.0

type key summary priority status

Data cannot be retrieved due to an unexpected error.

View these issues in Jira

2.3.4

type key summary priority status

Data cannot be retrieved due to an unexpected error.

View these issues in Jira

2.3.3

type key summary priority status

Data cannot be retrieved due to an unexpected error.

View these issues in Jira

2.3.2

type key summary priority status

Data cannot be retrieved due to an unexpected error.

View these issues in Jira

2.3.1

type key summary priority status

Data cannot be retrieved due to an unexpected error.

View these issues in Jira

2.3.0

type key summary priority status

Data cannot be retrieved due to an unexpected error.

View these issues in Jira

2.2.0

type key summary priority status

Data cannot be retrieved due to an unexpected error.

View these issues in Jira

2.1.0

type key summary priority status

Data cannot be retrieved due to an unexpected error.

View these issues in Jira

2.0.3

type key summary priority status

Data cannot be retrieved due to an unexpected error.

View these issues in Jira

2.0.2

type key summary priority status

Data cannot be retrieved due to an unexpected error.

View these issues in Jira

2.0.1

type key summary priority status

Data cannot be retrieved due to an unexpected error.

View these issues in Jira

2.0.0

type key summary priority status

Data cannot be retrieved due to an unexpected error.

View these issues in Jira

1.1.0

type key summary priority status

Data cannot be retrieved due to an unexpected error.

View these issues in Jira

1.0.0

type key summary priority status

Data cannot be retrieved due to an unexpected error.

View these issues in Jira
  • No labels

17 Comments

  1. Doesn't seem to be working with Bamboo 2.x?

    1. The current version is only for 1.2.4.

      I will be adding 2.0 support either today or tomorrow.

    2. 2.0 compatible version now available version

  2. This is probably some simple user error, but I'm running plugin version 2.0.1 with bamboo v2.0.4 and the post command simply doesn't run after a successful build. Log snippets:

    simple 12-Aug-2008 15:01:04 Executing build PLAT-NIGHTLY-59
    simple 12-Aug-2008 15:01:04 Running pre-build action: Build Number Stamper
    simple 12-Aug-2008 15:01:04 Running pre-build action: VCS Version Collector
    simple 12-Aug-2008 15:01:04 Running pre-build action: Pre Command Runner
    simple 12-Aug-2008 15:01:04 Building started with ScriptBuilder
    command 12-Aug-2008 15:01:04 Starting to build 'Platform - Nightly'<br /> ... running command line: /bin/sh build-script all<br /> ... in : /a/Bamboo/xml-data/build-dir/PLAT-NIGHTLY<br /> ... using java: null<br /> ... using environment variables:
    build 12-Aug-2008 15:01:04 /a/Bamboo/xml-data/build-dir/PLAT-NIGHTLY

    [...]
    build 12-Aug-2008 15:01:19 ...found 484 target(s)...
    simple 12-Aug-2008 15:01:19 Build process for 'Platform - Nightly' returned with return code = 0
    simple 12-Aug-2008 15:01:19 Running post build plugin 'Artifact Copier'
    simple 12-Aug-2008 15:01:19 Running post build plugin 'Clover Results Collector'
    simple 12-Aug-2008 15:01:19 Finalising the build...
    simple 12-Aug-2008 15:01:19 Stopping timer.
    simple 12-Aug-2008 15:01:19 Build PLAT-NIGHTLY-59 completed.
    simple 12-Aug-2008 15:01:19 Running post build plugin on server 'Clover Delta Calculator'

    I see a "Pre Command Runner" but no hint of any post commands despite the build being successful.  Atlassian support made some vague noises about "running my build on an agent" (the agent is local) but had no clue whether that would cause the plugin to run locally or ignore the configured commands or what.

    1. nm, found all my commands, conveniently located in a server-level log file totally inaccessible from the web interface.

      1. This is due to the fact that the post command runner plugin is a BuildCompleteAction.

        BuildCompleteActions do not log anything to the web interface's build log since they run after the build is finished.

        I plan to convert the post command plugin to a BuildProcessor instead of a BuildComplete Action which will allow you to see the output in the web interface, but only if it is running in the Bamboo build thread.  In v 2.1 of the plugin, you have the ability to run the command in a separate thread, and in that case, it will not log to the bamboo build log since it's in a separate thread.

         Hope that makes sense.

        - Jonathan

  3. Nice plugin (smile). Perhaps this is more of an Atlassian question - is it possible with the pre command to make changes to the build plan attributes that will take effect before the build gets run? For instance, modifying the build plan requirements that may affect what agents can process this instance of the build.

    1. Hey Bob,

      With the release of version 2.2.0, you now have the ability to specify if the pre command runs on the server or the agent.

      If you tell it to run on the server, the command actually gets run as a PreBuildQueuedAction which runs before the build is queued.
      In theory, I believe you should still be able to affect which agent picks up the build at this point by changing the requirements, but I haven't tested this.

      1. Jonathan, looks like a nice update (smile). Especially the server or agent option. I will have to check it out soon. Now, I just have to figure out how the requirements can be updated by a script. The rest APIs don't deal with that. I suppose tinkering with the database is possible. Perhaps a Bamboo developer can offer a suggestion?

  4. Is there a build home dir variable that can be used for simple commands like (on windows):

    post-build command:
    cmd /c del $

    Unknown macro: {bamboo.currentbuild.homedir}

    \test-report*.xml

  5. It would be great if there was a way to specify system variables like the builder does. I'm trying to use this to run my build script with the clean target before running the build so it always builds from a clean start. The problem is the build tool needs certain environment variables defined to find things. It works for the builder because I can pass in what it needs, but not for the prebuild command.

  6. I've just tried version 2.3.1 with Bamboo 2.1 but it's not working. (sad)
    I added a pre command then my build stopped with this log : Manual build triggered by admin

  7. I'm getting an error with Bamboo 2.2 and version 2.3.1 of the plugin when I'm running on the agent without running in a separate thread. I get this error:

    2009-03-21 10:52:54,218 ERROR :myhost::Agent BuildAgentControllerImpl Unknown error occurred on 'myhost' when building ODODEV-CMS-121. Agent will attempt process the build result...
    java.lang.NoClassDefFoundError: org/apache/commons/exec/ExecuteStreamHandler
    at com.sysbliss.bamboo.plugins.prepostcmd.runner.AbstractCommandRunner.execCommand(AbstractCommandRunner.java:74)
    at com.sysbliss.bamboo.plugins.prepostcmd.runner.AbstractCommandRunner.execute(AbstractCommandRunner.java:56)
    at com.sysbliss.bamboo.plugins.prepostcmd.runner.AbstractCommandRunner.run(AbstractCommandRunner.java:49)
    at com.sysbliss.bamboo.plugins.prepostcmd.action.PreBuildCommandAgentAction.call(PreBuildCommandAgentAction.java:48)
    at com.atlassian.bamboo.build.pipeline.tasks.PrepareBuildTask.call(PrepareBuildTask.java:59)
    at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:188)
    at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:89)
    at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:101)
    at com.atlassian.bamboo.build.pipeline.concurrent.NamedThreadFactory$1.run(NamedThreadFactory.java:32)
    at edu.emory.mathcs.backport.java.util.concurrent.helpers.ThreadHelpers$1.run(ThreadHelpers.java:34)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: java.lang.ClassNotFoundException: org.apache.commons.exec.ExecuteStreamHandler
    at com.atlassian.bamboo.agent.bootstrap.AgentClassLoader.findClass(AgentClassLoader.java:137)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at com.atlassian.bamboo.agent.bootstrap.AgentClassLoader.loadClass(AgentClassLoader.java:295)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    ... 11 more

    If I run in a separate thread I can't cause the build to fail on an error, which I need to be able to do. Is this a bug, or could it be a configuration
    issue on my side?

    1. Not sure why I'm getting the above error. The class in question, org/apache/commons/exec/ExecuteStreamHandler is packaged in the jar:

      40727 Thu Mar 19 11:54:36 PDT 2009 META-INF/lib/commons-exec-1.0-cs-01.jar

      I was able to bypass the problem by exploding commons-exec-1.0-cs-01.jar and repackaging prepost-build-command-2.3.1.jar. I don't think this should be necessary, but the plugin was failing otherwise for me.

    2. I get the same error with Bamboo 2.2.1 and 2.3.1 of the plugin. I'll probably work around it in the build instead of repackaging the jar as you did above so that I don't have to restart the server. Bummer this didn't work.

      1. I ended up repackaging the jar as a backup plan for when we did restart the server and we had the opportunity over the weekend. Now, though, I get the following error when looking at the Builder sub-tab in the Configuration tab for every build:

        Builder plugin not found for plan!

        Fortunately, I can still edit the plan there, see all the build settings and they seem to be correct; I just can't see them as part of the normal review page.